public static void main(String[] args) { String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory"; String MY_HOST = "ldap://Localhost:1389"; String MGR_DN = "cn=John,ou=Users,o=IT,dc=QuizPortal"; String MGR_PW = "password"; //Identify service provider to use Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,INITCTX); env.put(Context.PROVIDER_URL,MY_HOST); env.put(Context.SECURITY_AUTHENTICATION,"simple"); env.put(Context.SECURITY_PRINCIPAL,MGR_DN); env.put(Context.SECURITY_CREDENTIALS,MGR_PW); try { // Create the initial directory context InitialDirContext initialContext = new InitialDirContext(env); System.out.println("Context Sucessfully Initialized"); } catch(Exception e) { System.err.println(e); } }
我想询问何时将MGR_DN =“cn = John,ou = Users,o = IT,dc = QuizPortal”设置为MGR_DN =“uid = 103,dc = QuizPortal”.基本上从cn到uid,我会遇到一个错误
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
当我被指定为cn = John但不是uid = 103时我被认证.我不允许用uid指定吗?