7 Replies Latest reply on Jan 15, 2015 12:14 AM by valsaraj viswanathan

    WildFly External Context - LDAP

    valsaraj viswanathan Master

      Can anybody share how to setup the LDAP external context in WildFly 8.2?

        • 2. Re: WildFly External Context - LDAP
          valsaraj viswanathan Master

          Thanks Eduardo.

           

          I have used

          <subsystem xmlns="urn:jboss:domain:naming:2.0">

                      <bindings>

                          <external-context name="java:global/ldap" module="org.jboss.as.naming" class="javax.naming.ldap.InitialLdapContext" cache="true">

                              <environment>

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

                                  <property name="java.naming.provider.url" value="ldaps://localhost:636"/>

                                  <property name="java.naming.security.authentication" value="simple"/>

                       <property name="java.naming.security.principal" value="uid=admin,ou=system" />

                       <property name="java.naming.security.credentials" value="secret" />

                              </environment>

                          </external-context>

                      </bindings>

                      <remote-naming/>

                  </subsystem>

           

          and got the following error:

          ERROR [org.jboss.as.naming] (XNIO-1 task-1) JBAS011812: Failed to obtain jndi view value for entry ldap.: java.lang.RuntimeException: java.lang.NoSuchMethodException: javax.naming.ldap.InitialLdapContext.<init>(java.util.Hashtable)

           

          What may be the problem?

          • 3. Re: WildFly External Context - LDAP
            Eduardo Martins Apprentice

            Try class attribute with value javax.naming.directory.InitialDirContext, the value you used is a class that does not have the constructor with the standard environment map argument, which we internally use to build the initial context. I will update the docs to mention that requirement.

            1 of 1 people found this helpful
            • 4. Re: WildFly External Context - LDAP
              valsaraj viswanathan Master

              I am injecting resource like this:

              @Resource(lookup = "java:global/ldap")

                  private LdapContext ctx;

               

              Will that work in the same way if I used class attribute with value javax.naming.directory.InitialDirContext?

              • 5. Re: WildFly External Context - LDAP
                valsaraj viswanathan Master

                Hi Eduardo,


                I am getting this error when I access the EJB, java.lang.IllegalArgumentException: Can not set javax.naming.ldap.LdapContext field org.app.security.bean.SecurityBean.ctx to javax.naming.directory.InitialDirContext$$$$Proxy1.


                Here is my code and configuration:

                @Resource(lookup = "java:global/ldap")

                    private LdapContext ctx;

                 

                <external-context name="java:global/ldap" module="org.jboss.as.naming" class="javax.naming.ldap.InitialLdapContext" cache="true">

                                    <environment>

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

                                        <property name="java.naming.provider.url" value="ldaps://localhost:636"/>

                                        <property name="java.naming.security.authentication" value="simple"/>

                             <property name="java.naming.security.principal" value="uid=admin,ou=system" />

                             <property name="java.naming.security.credentials" value="secret" />

                                    </environment>

                                </external-context>

                • 6. Re: WildFly External Context - LDAP
                  Eduardo Martins Apprentice

                  Use javax.naming.directory.InitialDirContext as class attribute value, as I said before you can't use javax.naming.ldap.InitialLdapContext due to not having the required constructor.

                   

                  Wrt resource injection, when using javax.naming.directory.InitialDirContext you can inject the external context to that class or any interfaces it implements, which do not include LdapContext...

                  • 7. Re: WildFly External Context - LDAP
                    valsaraj viswanathan Master

                    Is it possible to inject to javax.naming.directory.InitialDirContext and then cast to javax.naming.ldap.InitialLdapContext to perform operations with LDAPv3-style controls and perform LDAPv3-style extended operations?