Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 6th, 2012  |  syntax: None  |  size: 0.32 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Convert domain name to LDAP-style in .NET
  2. string GetDomainDN(string domain)
  3. {
  4.     DirectoryContext context = new DirectoryContext(DirectoryContextType.Domain, domain);
  5.     Domain d = Domain.GetDomain(context);
  6.     DirectoryEntry de = d.GetDirectoryEntry();
  7.     return de.Properties["DistinguishedName"].Value.ToString();
  8. }