Active Directory get extensionAttribute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone explain to me how to find the value of a particular user's
extensionAttribute1 in C#.

I get this far and then have no idea what to do next.

DirectoryEntry dsDirectoryEntry = new DirectoryEntry("LDAP://domain",
username, password);

I don't understand how to use the DirectorySearcher class.

Thanks,

Phil
 
Can someone explain to me how to find the value of a particular user's
extensionAttribute1 in C#.

I get this far and then have no idea what to do next.

DirectoryEntry dsDirectoryEntry = new DirectoryEntry("LDAP://domain",
username, password);

I don't understand how to use the DirectorySearcher class.

Thanks,

Phil

Boy, it looks u need to go a long way from here....
anyways here the code....

oSearcher = new DirectorySearcher(oDirectoryEntry);
oSearcher.Filter="(&(objectClass=user)(objectCategory=user)
(sAMAccountName=Phil))"; // filter to get user accounts

oSearchCollection = oSearcher.FindAll(); // Finds all the user
accounts
if(oSearchCollection != null)
{
if(oSearchCollection.Count > 0)
{
foreach(SearchResult oResult in oSearchCollection) // gets each user
account into oResult.
{
if(oResult.Properties.Contains("extensionAttribute1")) // checks if
the user account has extensionAttribute1
{
sGroupDistinguishedName = oResult.Properties["extensionAttribute1"]
[0].ToString()
}
}
}
}

-
shashan kadge
 
Back
Top