【问题标题】:The user name or password is incorrect-8009030C: LdapErr: DSID-0C090579, comment: AcceptSecurityContext error, data 52e, v3839用户名或密码不正确-8009030C:LdapErr:DSID-0C090579,注释:AcceptSecurityContext错误,数据52e,v3839
【发布时间】:2019-07-11 08:15:12
【问题描述】:

我正在尝试使用以下代码连接 AD

VMADProfile _VMADProfile = new VMADProfile();
DirectoryEntry searchRoot = new DirectoryEntry("Test AD LDAP Path", "DomainName\\username", "password");
directorySearcher.Filter = "(&(objectCategory=user)(samAccountName=" + username + "))";    
directorySearcher.PropertiesToLoad.Add("displayname");    
SearchResult one = directorySearcher.FindOne();

但它给了我以下错误

 The user name or password is incorrect.
8009030C: LdapErr: DSID-0C090579, comment: AcceptSecurityContext error, data 52e, v3839

如果我直接登录,我可以使用相同的用户名和密码登录。 我尝试连接的 AD 与我正在运行的代码不同。如果我将测试广告更改为生产广告,则相同的代码可以正常工作

【问题讨论】:

  • 错误 52e 表示凭据无效,即密码不正确。
  • 正如我提到的密码是正确的,我可以使用相同的 AD 登录到服务器
  • 我只是说错误的含义。密码中可以包含非 ascii 字符吗?
  • 是的,我已经有了大写小写特殊字符和数字
  • 那么可能是字符集问题。 Latin1 与 Unicode。

标签: c# .net authentication active-directory ldap


【解决方案1】:

我认为这是关键:

我尝试连接的 AD 与我正在运行的代码不同。

它可能试图在您的域上验证您的身份,而不是另一个。确保您的 LDAP 路径包括要连接到其他域的服务器,而不仅仅是域的专有名称。服务器名称可以只是域的 DNS 名称。它应该看起来像这样:

DirectoryEntry searchRoot = new DirectoryEntry("LDAP://otherdomain.com/DC=otherdomain,DC=com", "DomainName\\username", "password");

如果您只使用"LDAP://DC=otherdomain,DC=com",它将尝试连接到当前计算机首先加入的域。如果两个域之间存在信任,这实际上会起作用,但如果没有,则需要专门为其提供要连接的服务器名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-03
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    • 2021-10-08
    • 2014-04-02
    • 1970-01-01
    相关资源
    最近更新 更多