6 Replies Latest reply on Jan 1, 2010 1:54 PM by Celinio Fernandes

    [JBoss 6.0 M1] Connection to LDAP server through LdapExtLoginModule

    Celinio Fernandes Novice

      Hi,

      I have been battling for days to make that LDAP connection work.

      Here is my login-config.xml file :

       

       <application-policy name="venteEnLigne_domaine_LDAP">
               <authentication>
                   <login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required" >
                       <module-option name="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</module-option>
                       <module-option name="java.naming.provider.url">ldap://localhost:10389</module-option>
                       <module-option name="java.naming.security.authentication">simple</module-option>
                     
                       <module-option name="bindDN">uid=log6,ou=users,ou=system</module-option>
                       <module-option name="bindCredential">pwd6</module-option>
                      
                        <module-option name="baseCtxDN">ou=users,ou=system</module-option>
                      
                       <module-option name="principalDNPrefix">uid=</module-option>                   
                   <module-option name="principalDNSuffix">,ou=users,ou=system</module-option>
                               
                       <module-option name="searchScope">ONELEVEL_SCOPE</module-option>
                       <module-option name="allowEmptyPasswords">true</module-option>
                 </login-module>
               </authentication>
           </application-policy>

       

      I can connect to the LDAP server through this program :

       

       String url = "ldap://localhost:10389/ou=users,ou=system";
                  String userName = "log6";
                  String password = "pwd6";
                  String base = "ou=users,ou=system";
                  String dn = "uid=" + userName + "," + base;
                 
                  Hashtable env = new Hashtable();
                  env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
                  env.put(Context.PROVIDER_URL, url);
                  env.put(Context.SECURITY_AUTHENTICATION, "simple");
                  env.put(Context.SECURITY_PRINCIPAL, dn);
                  env.put(Context.SECURITY_CREDENTIALS, password);
                  DirContext context = new InitialDirContext(env);
                  System.out.println("Authentication Success!");
                

       

      But i cannot connect when i use these lines, I do not even get any error message :

       

      import org.jboss.security.client.SecurityClient;
      import org.jboss.security.client.SecurityClientFactory;

      ...

      SecurityClient securityClient;

      securityClient = SecurityClientFactory.getSecurityClient();

      securityClient.setSimple("log6", "pwd6");                            
                      securityClient.login();

       

      I know the connection is not working because when i try to access an EJB method with restricted access, it fails (Invalid user).

      Does anyone know what's wrong and how to fix this ?

       

      That would be a really nice way to end the year 2009 and start the year 2010.

      Happy new year !

      And thanks in advance.