LDAP:错误代码49 - 80090308:LdapErr:DSID-0C0903A9,注释:AcceptSecurityContext错误,数据52e,v1db1

时间:2015-07-14 15:59:04

标签: authentication ldap

  

LDAP:错误代码49 - 80090308:LdapErr:DSID-0C0903A9,注释:AcceptSecurityContext错误,数据52e,v1db1

我知道“52e”代码是当用户名有效时,但密码无效。我在apache studio中使用相同的用户名和密码,我能够成功建立与LDAP的连接。

这是我的java代码

    String userName = "*******";
    String password = "********";
    String base ="DC=PSLTESTDOMAIN,DC=LOCAL";
    String dn = "cn=" + userName + "," + base;  
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://******");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, dn);
    env.put(Context.SECURITY_CREDENTIALS, password);
    LDAPAuthenticationService ldap = new LDAPAuthenticationService();
   // LdapContext ctx;
    DirContext ctx = null;
    try {
        ctx = new InitialDirContext(env);

我的错误就在这一行ctx = new InitialDirContext(env);

我不知道究竟是什么导致了这个错误。

11 个答案:

答案 0 :(得分:20)

对我来说,当我设置这样的主要部分时,问题就解决了:

env.put(Context.SECURITY_PRINCIPAL, userId@domainWithoutProtocolAndPortNo);

答案 1 :(得分:12)

52e 1326 ERROR_LOGON_FAILURE当用户名有效但密码/凭证无效时返回。将防止显示大多数其他错误。

http://ldapwiki.com/wiki/Common%20Active%20Directory%20Bind%20Errors

答案 2 :(得分:6)

当将Context.SECURITY_AUTHENTICATION用作“简单”时,需要提供userPrincipalName属性值(user @ domain_base)。

答案 3 :(得分:4)

在CAS上使用AD时出现了类似的问题,即52e错误,在我的情况下,应用程序在CN =而不是实际用户名时接受全名。

例如,如果你有一个用户的全名是Ross Butler并且他们的登录用户名是rbutler - 你通常会输入类似的东西,例如cn = rbutler,ou = Users,dc = domain,dc = com但是我们的失败了每次。通过将此更改为cn = Ross Butler,ou = Users,dc = domain,dc = com它已通过!!

答案 4 :(得分:3)

就我而言,我必须使用类似@的名称才能成功登录。

sample_user @ sample_domain

答案 5 :(得分:2)

对我来说,通过在用户名中添加域名来解决此问题,如下所示:

string userName="yourUserName";
string password="passowrd";
string hostName="LdapServerHostName";
string domain="yourDomain";
System.DirectoryServices.AuthenticationTypes option = System.DirectoryServices.AuthenticationTypes.SecureSocketsLayer; 
string userNameWithDomain = string.Format("{0}@{1}",userName , domain);
DirectoryEntry directoryOU = new DirectoryEntry("LDAP://" + hostName, userNameWithDomain, password, option);

答案 6 :(得分:2)

如果您调试并查看ctx = null,也许您的用户名hava问题,您应该这样写: “ ac \ administrator”(双“ \”)或“ administrator @ ac”

答案 7 :(得分:1)

在将事务发送到另一个服务器数据库时,LDAP正在尝试使用AD进行身份验证。此身份验证失败,因为用户最近更改了密码,尽管此事务是使用以前的凭据生成的。此身份验证将一直失败,直到...除非您将事务状态更改为“完成”或“取消”,在这种情况下,LDAP将停止发送这些事务。

答案 8 :(得分:0)

对我来说,通过更改环境可以解决此问题:

 env.put("LDAP_BASEDN", base)
 env.put(Context.SECURITY_PRINCIPAL,"user@domain")

答案 9 :(得分:0)

使用域名可以解决问题(使用powershell获取域名: $ env:userdomain ):


$input = [
    'id_coretable'          => 1,
    'Internal_key'          => 'TESTKEY_1',
    'extensiontable_itc'    => [
        'description_itc' => 'EXTENSION_ITC_1',
    ],
    'extensiontable_sysops' => [
        'description_sysops' => 'EXTENSION_SYSOPS_1',
    ],
];

$permittedTables = ['extensiontable_itc', 'extensiontable_sysops'];
$core            = Core::with($permittedTables)->find(1);

// Update extensiontable_itc
$core->extensiontable_itc->update($input['extensiontable_itc']);

// Update extensiontable_sysops
$core->extensiontable_sysops->update($input['extensiontable_sysops']);

答案 10 :(得分:0)

对我来说,问题的原因是用户名的格式不正确。它早先被指定为“mydomain\user”。我删除了域部分,错误消失了。

PS 我使用的是 ServerBind 身份验证。

相关问题