Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ActiveDirectory (DirectoryEntry) Set/Get Attributes - Cached?

ActiveDirectory (DirectoryEntry) Set/Get Attributes - Cached?

Scheduled Pinned Locked Moved C#
sysadminperformancehelpquestion
2 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sir Dot Net
    wrote on last edited by
    #1

    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();
    }

    S 1 Reply Last reply
    0
    • S Sir Dot Net

      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();
      }

      S Offline
      S Offline
      Sir Dot Net
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups