views:

413

answers:

1

Trying to use this code to connect the AD

PrincipalContext context = new PrincipalContext(ContextType.Domain, domain)

but i got the error saying:

"The LDAP server is unavailable."

Any idea?

+1  A: 

The questions is: do you specify our domain as

  • "mydomain.com" (DNS format)
  • or as "dc=mydomain,dc=com" (AD-style format)

To my surprise, the Domain name must be in DNS format (e.g. "mydomain.com") in order for this to work (and NOT in the usual AD-style format of "dc=mydomain,dc=com").

Marc

marc_s
Thanks.I knew that i need to use the domain name without the AD style format. i that found my error was that the domain name string contained the "LDAP://" keyword, this is why the connection failed.You helped me to notice my mistake.Thank you man.Tamir
Tamir