User Management with Active Directory—Retrieving the Users Token Groups

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

User Management

© 2006 Pearson Education, Inc.

Retrieving the User’s Token Groups

Regardless of the technique we choose to decode the tokenGroups attribute, we must first retrieve it. Since this is a constructed attribute, we must use the RefreshCache technique shown in Chapter 3 to first load the attribute into the property cache in a DirectoryEntry object. This is one of the few attributes that requires a Base search scope with DirectorySearcher, so we will generally choose to use a DirectoryEntry instance for this work instead:

//user is a DirectoryEntry
user.RefreshCache(
  new string[] {"tokenGroups"}
  );
 
//now the attribute will be available
int count = user.Properties["tokenGroups"].Count;
 
Console.WriteLine(
  "Found {0} Token Groups",
  count
  );


Previous_Page_.gif Next_Page_.gif

Personal tools