有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在Java凭据中通过LDAP进行身份验证错误,即使使用已验证的凭据也是如此

我有一个简单的Java代码块,用于通过LDAP对用户进行身份验证。这是一个简单的功能,可以在网上的许多地方找到:

public static void main(String[] args) {

    String user = "cn=userid@my.domain.net,ou=users,dc=my,dc=domain,dc=net";
    String password = "password";
    String ldapHost = "ldap://my.domain.net";
    String ldapPort = "999";
    // TODO Auto-generated method stub
    try {
         Hashtable props = new Hashtable();
            props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
            props.put(Context.SECURITY_AUTHENTICATION,"Simple");
            props.put(Context.SECURITY_PRINCIPAL, user);
            props.put(Context.SECURITY_CREDENTIALS, password);
            props.put(Context.PROVIDER_URL, ldapHost + ":" + ldapPort);

            LdapContext ldapCtxt = new InitialLdapContext(props, null);
            System.out.println("ldapCtxt "+ldapCtxt.toString());

    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

但我一直收到以下错误:

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

我知道这个错误是一个凭证错误,根据文档和其他论坛,十六进制值52e表示用户名有效,但密码无效。然而,我也看到了一些证据,表明这个错误会阻止其他错误的显示,我认为这误导了我的调试工作

我使用的凭据已被验证为正确,而且,当我将用户名更改为一个无意义的字符串时,我知道它不正确,,仍然会发生相同的错误

除了有效用户名和无效密码组合之外,是否还有其他原因导致显示此错误


共 (0) 个答案