Reputation: 31
I use the System.DirectoryServices.Protocols.DirSyncRequestControl with a cookie to sync only the objects which were changed since the last sync from Active Directory to a SQL-Database. On first sync (cookie is null) everythings works fine, but on a later diff-sync the search only return the changed attributes of the object and not the whole list of properties I asked for.
SearchRequest Request = new SearchRequest(RootDSE.Properties["defaultNamingContext"].Value.ToString(), "(|(objectClass=user)(objectClass=group)(objectClass=contact))", System.DirectoryServices.Protocols.SearchScope.Subtree, propertiesToLoad);
DirSyncRequestControl DirSyncRC = new DirSyncRequestControl(cookie, System.DirectoryServices.Protocols.DirectorySynchronizationOptions.None, Int32.MaxValue);
Request.Controls.Add(DirSyncRC);
SearchResponse SearchResponse = (SearchResponse)Connection.SendRequest(Request);
foreach (SearchResultEntry Entry in SearchResponse.Entries)
{
...
}
I thought that setting the DirectorySynchronizationOptions to None would work but unfortunately it doesn't.
So is there a way to always return a full set of definded attributes if even one of the attribute changes?
Thanks in advance
Upvotes: 2
Views: 761
Reputation: 705
Dirsync control will return you only attributes that were changed. To get additional user properties you have 2 options: 1. Make an additional LDAP query to retrieve attributes needed. 2. Use usn based change tracking technique
Upvotes: 1