Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am using the following code to get the fully distinguished domain name of the manager field of various users across a domain. I would like to get the actual windows username of the manager in the shortest number of lines possible. Would someone be kind enough to explain the easiest way of getting the username of the manager from the fully distinguished domain name?

Thanks!

C#
DirectorySearcher dSearch = new DirectorySearcher("LDAP ConnString");
dSearch.Filter = "(sAMAccountName=" + txtUsername.Text + ")";
SearchResult sResult = dSearch.FindOne();
DirectoryEntry dResult = sResult.GetDirectoryEntry();

string strRawManager = dResult.Properties["manager"][0].ToString();
Posted
Comments
Sergey Alexandrovich Kryukov 17-May-15 10:22am    
Is the "shortest number of lines" your goal? What's in input?
How come manager name comes into domain name?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900