Sumply return the path of AD when executed on a domain.
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;
}
}
Steven M. Swafford
http://radicaldevelopment.net
Dont forget to click "Mark as Answer" on the post that helped you.