On May 4, 12:57 pm, Phil <P...@discussions.microsoft.comwrote:
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)(objectCateg ory=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("extensionAttribute 1")) // checks if
the user account has extensionAttribute1
{
sGroupDistinguishedName = oResult.Properties["extensionAttribute1"]
[0].ToString()
}
}
}
}
-
shashan kadge