Reputation: 3921
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?
Upvotes: 10
Views: 12318
Reputation: 4527
I had the same problem.
Mine was because the webserver was not on the same domain as the user.
I resolved it by ignoring the error; this then forced an authentication challenge which enabled the user to supply credentials, which I could pick up the correct domain from.
Upvotes: 0
Reputation: 755321
The questions is: do you specify our domain as
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").
Upvotes: 16