Directory Entry/ Directory Searcher question
Hello -
I am in a situation where I wish to gather information thru the Active Directory Domain:
DirectoryEntry entry = new DirectoryEntry();
entry.Path = "LDAP://DC=xxxx"
entry.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher search = DirectorySearcher(entry);
search.PropertiesToLoad.Add("givenName");
search.PropertiesToLoad.Add("memberof");
search.PropertiesToLoad.Add("sAMAccountName");
SearchResultCollection result = search.FindAll();
So far everything works fine. Returns some 1163 entries. What I want to do now is loop through the entries and gather the individual values for givenName, memberof, etc.
foreach (SearchResult sr in result)
{
*****************************************
strName = sr.Properties["givenName"].ToString();
this statement stores the literal
"System.DirectoryServices.ResultPropertyValueCollection"
in the local string variable strName
***********************************
}
What the heck am I missing?
Thanks in advance...