/ Published in: C#

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
string sAMAccountName = "<login name>"; string filter = string.Format("(&(ObjectClass={0})(sAMAccountName={1}))", "person", sAMAccountName); //you must provide a username and password to authenticate (this is not the username and password of the person you're looking for): searcher.SearchScope = SearchScope.Subtree; searcher.ReferralChasing = ReferralChasingOption.All; searcher.PropertiesToLoad.AddRange(properties); searcher.Filter = filter; SearchResult result = searcher.FindOne(); DirectoryEntry de = result.GetDirectoryEntry(); //you can now get the properties of the directory entry this way: string property = de.Properties["<property name>"].Value.ToString(); /*some examples of property names: co (country) c (country abbreviation) countryCode givenName (first name) title mobile sAMAccountName sn (last name) st (state) street streetAddress telephoneNumber postalCode */
Comments
