1

weblogic '10.3.4.0' をインストールし、ドメインを作成し、デフォルト セキュリティ レルムにbusinessユーザーを作成しました。オーセンティケータは、weblogic と同様です。ここで、LDAP を使用してスタンドアロンの Java アプリケーションでユーザーを認証したいと考えています。また、LDAP 資格情報を変更しようとしました。アプリケーションの実行後、システムは次のエラーで応答しています: 。businessusermyrealmDefaultAuthenticatorjavax.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)
4

1 に答える 1

1

これを試して:

package br.com.cliente.projeto;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;


public class Autenticacao
{
  @SuppressWarnings({ "unchecked", "deprecation" })
public static void main(String args[])
  {

      String username = "jstein";  
      String password = "welcome1";  

      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); 
      env.put(Context.SECURITY_PRINCIPAL, username);
      env.put(Context.SECURITY_CREDENTIALS, password);
      env.put(Context.PROVIDER_URL, "t3://10.19.2.99:7001");
      try {  
          InitialContext ctx = new InitialContext(env);
          System.out.println("Autenticado");  
      } catch (Exception e) {  
          e.printStackTrace();  
      }  

  }
}
于 2014-02-24T17:43:41.620 に答える