【问题标题】:LDAP invalid credentials - Active Directory Windows Server 2012 R2LDAP 无效凭据 - Active Directory Windows Server 2012 R2
【发布时间】:2019-04-25 10:05:28
【问题描述】:

我以前没有使用过 Active Directory,我需要在 C# 中的 Unity 独立实现和通过 LDAP 安装在 Windows Server 2012 R2 上的 Active Directory 之间建立连接。每次连接时,我都会收到相同的错误:

LdapException: (49) 无效的凭证 LdapException:服务器消息:8009030C:LdapErr:DSID-0C0903C5,注释:AcceptSecurityContext 错误,数据 2030,v2580

我确信我的用户名和密码是正确的。

DirectoryEntry entry = new DirectoryEntry("LDAP://"+ serverName+":"+port,userName,password);

    DirectorySearcher ds = new DirectorySearcher(entry);

    ds.Filter = "XX";

    SearchResult result = ds.FindOne();
    ResultPropertyCollection rpc = result.Properties;
    foreach (string property in rpc.PropertyNames)
    {
        foreach (object value in rpc[property])
            console.text+="Property = " + property + "Value = " + value;
    }
}
catch (Exception ex)
{
    Debug.Log(ex);
}

我已经尝试过使用 LdapAdmin(开源 LDAP 目录管理工具),但即使在 Windows PowerShell 中使用 ldp 命令行,我也收到了同样的错误。任何帮助将不胜感激。 Screenshot

【问题讨论】:

  • 你能展示你的代码吗?
  • userName中的用户名格式是什么?是domain\username 还是username@domain.com? (请编辑您的问题而不是添加答案)
  • 我都试过了,但都出现同样的错误,你能检查一下我最近添加的截图吗?感谢您的宝贵时间。
  • 请看下面的答案。你的用户名一定有错别字。这不是在骗你:)

标签: active-directory ldap windows-server-2012-r2


【解决方案1】:

这很模糊,但您被拒绝的原因在错误消息中。真正的错误是data 字段的值。在这种情况下,错误是0x2030

将值转换为十进制得到8240

然后查找错误。 FormatMessage API will give you that,或者在命令行上,你会这样做:

net helpmsg 8240

你会得到

There is no such object on the server.

这意味着您使用的用户名不存在,有错别字等。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多