DirectoryEntry searchroot = new DirectoryEntry("LDAP://dc=yourdomainname,dc=com");
DirectorySearcher ds = new DirectorySearcher(searchroot);
ds.SearchScope = SearchScope.Subtree;
ds.Filter = "(&(objectclass=user)(samaccountname="+ wi.Name +"))";
SearchResultCollection searchResults = ds.FindAll();
string UserDetails = searchResults [0].GetDirectoryEntry().Properties["distinguishedname"].Value
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Open in new window