Last active
December 19, 2015 11:59
-
-
Save billtaichi/5951508 to your computer and use it in GitHub Desktop.
Snippet to obtain Active Directory Path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string ActiveDirectoryPath() | |
{ | |
DirectoryEntry root = new DirectoryEntry("LDAP://RootDSE"); | |
using (root) | |
{ | |
string dnc = root.Properties["defaultNamingContext"][0].ToString(); | |
string server = root.Properties["dnsHostName"][0].ToString(); | |
string adsPath = String.Format("LDAP://{0}/{1}", server, dnc); | |
return adsPath; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment