Is there a built-in C# function to convert a dot-style domain name (my.domain.name) to LDAP style domain components (dc=my,dc=domain,dc=component?
string GetDomainDN(string domain)
{
DirectoryContext context = new DirectoryContext(DirectoryContextType.Domain, domain);
Domain d = Domain.GetDomain(context);
DirectoryEntry de = d.GetDirectoryEntry();
return de.Properties["DistinguishedName"].Value.ToString();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With