Trying to use this code to connect the AD
尝试使用此代码连接AD
PrincipalContext context = new PrincipalContext(ContextType.Domain, domain)
but i got the error saying:
但我得到错误说:
The LDAP server is unavailable.
LDAP服务器不可用。
Any idea?
2 个解决方案
#1
The questions is: do you specify our domain as
问题是:您是否将我们的域指定为
- "mydomain.com" (DNS format)
- or as "dc=mydomain,dc=com" (AD-style format)
“mydomain.com”(DNS格式)
或者作为“dc = mydomain,dc = com”(AD样式格式)
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").
令我惊讶的是,域名必须采用DNS格式(例如“mydomain.com”)才能实现(而不是通常的AD风格格式“dc = mydomain,dc = com”)。
#2
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.
我通过忽略错误来解决它;然后强制进行身份验证质询,使用户能够提供凭据,我可以从中获取正确的域名。
#1
The questions is: do you specify our domain as
问题是:您是否将我们的域指定为
- "mydomain.com" (DNS format)
- or as "dc=mydomain,dc=com" (AD-style format)
“mydomain.com”(DNS格式)
或者作为“dc = mydomain,dc = com”(AD样式格式)
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").
令我惊讶的是,域名必须采用DNS格式(例如“mydomain.com”)才能实现(而不是通常的AD风格格式“dc = mydomain,dc = com”)。
#2
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.
我通过忽略错误来解决它;然后强制进行身份验证质询,使用户能够提供凭据,我可以从中获取正确的域名。