1 Reply Latest reply on Mar 22, 2018 12:17 PM by Martin Choma

    Wildfly LDAP login from java webapp

    Néstor Almeida Newbie

      Hi people,


      I want to add a login feature to my web portal using a form embedded in my index page.

      The form invoke a JSF actionlistener that validate the user and return the outcome to the next page...

      I want to validate the users against a LDAP server but I dont want to do explicit in the java code, I would like to use the JBoss subsystem to do that so in the standalone.xml I defined a security domain:     


                     <security-domain name="LOCAL_LDAP" cache-type="default">


                              <login-module code="LdapExtended" flag="required">

                                  <module-option name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>

                                  <module-option name="java.naming.provider.url" value="ldap://localhost:10389"/>

                                  <module-option name="java.naming.security.authentication" value="simple"/>

                                  <module-option name="bindDN" value="uid=admin,ou=system"/>

                                  <module-option name="bindCredential" value="password"/>

                                  <module-option name="baseCtxDN" value="o=canarias.org,c=es"/>

                                  <module-option name="baseFilter" value="(uid={0})"/>

                                  <module-option name="searchScope" value="SUBTREE_SCOPE"/>

                                  <module-option name="throwValidateError" value="true"/>

                                  <module-option name="allowEmptyPasswords" value="false"/>

                                  <module-option name="roleRecursion" value="1"/>

                                  <module-option name="defaultRole" value="GCID"/>





      then I add it to my webapp:



         <security-domain flushOnSessionInvalidation="true">LOCAL_LDAP</security-domain> 



      All examples I saw uses the web.xml to define a security login but I want to call it directly from my java code.


      User load index page, fill the user and password, the form action validates the user, then load the principal. I dont want to provide a specific form like form login do.


      A don't want to pass any value to my webapp because I want to deploy it in a large number of locations so I want to delegate the config to the JBoss standalone file.


      It's possible to do that?


      Thanks you very much,


      Nestor Almeida.