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);
}
}
me gustaría preguntar cuando me puse la MGR_DN = "cn=John,ou=Users,o=IT,dc=QuizPortal"
a MGR_DN = "uid=103,ou=Users,o=IT,dc=QuizPortal"
. Básicamente se cambia de CN a uid, me gustaría encontrar un errorLDAP autenticación de contraseña de usuario utilizando JNDI
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
estoy autenticado cuando se especifica como cn=John
pero no uid=103
. ¿No puedo especificar por uid?
¡Oh ... GRACIAS! Entendido ... me preguntaba por qué no funcionó ... GRACIAS – Nivek
Depende del directorio LDAP. Algunos permiten atributos de nomenclatura alternativos, en cuyo caso uid = 103 podría funcionar. Mientras que otros no lo harán. Por lo tanto, no es un enfoque confiable. – geoffc