簡體   English   中英

LDAP驗證問題

[英]LDAP Authentication Issue

我必須連接到LDAP,但是我無法使用Java代碼進行連接,並且使用LDAPAdmin工具也可以連接。

String url = "ldap://host name:389";
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");   
ldapEnv.put(Context.PROVIDER_URL,  url);   
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
ldapEnv.put(Context.SECURITY_PRINCIPAL, "CN=username");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "#1223");

錯誤

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

一旦看這個..這對我來說很好,這可能會幫助您。 謝謝..

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
public class LdapContextCreation {
    public static void main(String[] args) {
        LdapContextCreation ldapContxCrtn = new LdapContextCreation();
        LdapContext ctx = ldapContxCrtn.getLdapContext();
    }
        public LdapContext getLdapContext(){
            LdapContext ctx = null;
            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, "cn=company,dc=example,dc=com");         
            env.put(Context.SECURITY_CREDENTIALS, "pasword");          
            env.put(Context.PROVIDER_URL, "ldap://localhost:389"); 
            try{
            ctx = new InitialLdapContext(env, null);           
            System.out.println("Connection Successful.");  
            }catch(NamingException nex){       
                System.out.println("LDAP Connection: FAILED");      
                nex.printStackTrace();
                }      
            return ctx;
                }

        }

在這里查看錯誤代碼-http: //www-01.ibm.com/support/docview.wss?uid=swg21290631

數據52e-根據鏈接,52e表示無效的憑據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM