Tuesday 14 October 2008

Active directory group and member properties, DirectorySearcher PropertiesToLoad possible values

Normally you would use code like this, to retrieve values for specific properties of an Active Directory group (specified in string groupName):


   1:  DirectorySearcher search = new DirectorySearcher {Filter = String.Format("(cn={0})", groupName)};
   2:  search.PropertiesToLoad.Add("member"); 
   3:   
   4:  List<string> userNames = new List<string>();
   5:   
   6:  if (result != null)
   7:  {
   8:     for (int counter = 0; counter < result.Properties["member"].Count; counter++)  
   9:     {
  10:        string user = (string)result.Properties["member"][counter];
  11:        userNames.Add(user + Environment.NewLine);
  12:     }
  13:  }
  14:   
  15:  return userNames;

but what are the possible values of properties you can use in PropertiesToLoad.Add()? I couldnt find this information anywhere so I wrote a little snippet to retrieve them, here is the result (29 properties)

textencodedoraddress
distinguishedname
dscorepropagationdata
grouptype
objectsid
whencreated
msexchalobjectversion
mailnickname
name
usnchanged
objectcategory
samaccounttype
instancetype
reporttooriginator
cn
proxyaddresses
showinaddressbook
objectclass
mail
usncreated
member
objectguid
adspath
displayname
legacyexchangedn
samaccountname
whenchanged
memberof
msexchpoliciesincluded

No comments: