首页 > 解决方案 > LDAP 无效凭据 - Active Directory Windows Server 2012 R2

问题描述

我以前没有使用过 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 命令行,我也收到了同样的错误。任何帮助将不胜感激。 截屏

标签: active-directoryldapwindows-server-2012-r2

解决方案


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

将值转换为十进制以获取8240.

然后查找错误。FormatMessage API 将为您提供,或者在命令行上,您将执行以下操作:

net helpmsg 8240

你会得到

There is no such object on the server.

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


推荐阅读