我已经安装了 weblogic '10.3.4.0' 并创建了一个域并在默认安全领域business
创建了一个用户。身份验证器与 weblogic 中的一样。现在,我想在我的独立 java 应用程序中使用 LDAP 对用户进行身份验证。我也尝试过更改 LDAP 凭据。执行应用程序后,系统响应以下错误:。businessuser
myrealm
DefaultAuthenticator
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
代码:
Properties l_props = new Properties();
LdapContext l_ctx = null;
l_props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
l_props.put(Context.PROVIDER_URL, "ldap://localhost:7001");
l_props.put(Context.SECURITY_AUTHENTICATION, "simple");
l_props.put(Context.SECURITY_PRINCIPAL, "cn=username");
l_props.put(Context.SECURITY_CREDENTIALS, "password");
l_ctx = new InitialLdapContext(l_props, null);
错误:
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3041)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2789)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2703)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
at com.iflex.fcat.misc.TestLDAP.createInitialLdapContext(TestLDAP.java:258)
at com.iflex.fcat.misc.TestLDAP.authenticate(TestLDAP.java:170)
at com.iflex.fcat.misc.TestLDAP.main(TestLDAP.java:125)