ActiveDirectory (DirectoryEntry) Set/Get Attributes - Cached?
-
Anyone know what I can do about this. I'm getting a user DirectoryEntry, modifying an attribute value, then committing the changes, and closing the entry, but on subsequent calls (re-get user directory->get attribute value), the value is the original... until about 10-15 seconds later. I've tried using the RefreshCache method, and the UsePropertyCache property on the DirectoryEntry, but nothing seems to work. I don't understand why the value isn't set immediately (this is a dev ADAM server w/ virtually no load, it shouldn't be a performance issue). Setting:
using ( DirectoryEntry entry = FindUserDirectoryEntry( username ) ) {
if ( entry != null ) {
if ( entry.Properties.Contains( attributeName ) ) {
entry.Properties[attributeName].Value = value;
} else if ( value.IsEmpty() == false ) {
entry.Properties[attributeName].Add( value );
}
entry.CommitChanges();
entry.Close();
}
}Getting:
DirectoryEntry entry = this.ADAMProvider.GetUserDirectoryEntry( userName );
if ( entry != null ) {
if ( entry.Properties.Contains( attributeName ) ) {
entry.RefreshCache(attributeName);
value = entry.Properties[attributeName].Value.SafeToString();
}
entry.Close();
} -
Anyone know what I can do about this. I'm getting a user DirectoryEntry, modifying an attribute value, then committing the changes, and closing the entry, but on subsequent calls (re-get user directory->get attribute value), the value is the original... until about 10-15 seconds later. I've tried using the RefreshCache method, and the UsePropertyCache property on the DirectoryEntry, but nothing seems to work. I don't understand why the value isn't set immediately (this is a dev ADAM server w/ virtually no load, it shouldn't be a performance issue). Setting:
using ( DirectoryEntry entry = FindUserDirectoryEntry( username ) ) {
if ( entry != null ) {
if ( entry.Properties.Contains( attributeName ) ) {
entry.Properties[attributeName].Value = value;
} else if ( value.IsEmpty() == false ) {
entry.Properties[attributeName].Add( value );
}
entry.CommitChanges();
entry.Close();
}
}Getting:
DirectoryEntry entry = this.ADAMProvider.GetUserDirectoryEntry( userName );
if ( entry != null ) {
if ( entry.Properties.Contains( attributeName ) ) {
entry.RefreshCache(attributeName);
value = entry.Properties[attributeName].Value.SafeToString();
}
entry.Close();
}Ok... nvm... found my own answer. Turns out that I have to set the CacheResults on the DirectorySearcher (that finds my DirectoryEntry) to false. Now everything works immediately!