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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/56325782/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:16:15  来源:igfitidea点击:

LDAP: error code 49 - 80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580

javaauthenticationldap

提问by Krishna

LDAP: error code 49 - 80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580

I know "52e" code is when username is valid, but password is invalid. I am using the same user name and password for validating user against Active directory and its working fine.

我知道“52e”代码是用户名有效但密码无效的时候。我使用相同的用户名和密码来验证用户针对 Active Directory 及其工作正常。

Here is my java code:

这是我的Java代码:

        String userName = "user_test";
        String password =  "*******";
        String base ="DC=test,DC=local";
        String dn = "cn="+ userName + "," + "CN=Users," + base;  

        try {
            Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
            env.put(Context.SECURITY_AUTHENTICATION, "simple");

            env.put(Context.SECURITY_PRINCIPAL, dn);

            env.put(Context.SECURITY_CREDENTIALS, password);

            env.put(Context.PROVIDER_URL, "ldap://*****.test.local:389");


            System.out.println("Attempting to Connect...");

            ctx = new InitialLdapContext(env, null);
            System.out.println("Connection Successful.");
        } catch (NamingException nex) {
            System.out.println("LDAP Connection: FAILED");
            nex.printStackTrace();
        }
        return ctx;
    }

I do not know exactly why getting this error. Can anyone please help on this?

我不知道为什么会出现此错误。任何人都可以帮忙吗?

回答by Alister

In case you use simple authority authentication , you should use short username form

如果您使用简单的权限认证,您应该使用简短的用户名形式

[email protected]

[email protected]

I checked, in this case authentication is working. In dn form I have got exactly the same error

我检查过,在这种情况下,身份验证有效。在 dn 形式中,我得到了完全相同的错误

javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1

You may also refer to earlier thread LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1

您也可以参考之前的线程LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1