C# 尝试使用 LDAP 连接连接 AD 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1023489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error while trying to connect AD using LDAP connection
提问by Tamir
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?
任何的想法?
采纳答案by marc_s
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 NOTin the usual AD-style format of "dc=mydomain,dc=com").
令我惊讶的是,域名必须采用DNS 格式(例如“mydomain.com”)才能使其正常工作(而不是通常的 AD 样式格式“dc=mydomain,dc=com”)。
回答by CompanyDroneFromSector7G
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.
我通过忽略错误解决了它;然后强制进行身份验证质询,使用户能够提供凭据,我可以从中获取正确的域。