1

We are in the process of moving from Glassfish to WildFly. In Glassfish we setup our LDAP server and use it for authentication and we also reference it with JNDI for us within the application for things such as searching users, etc. I am wondering if there is a way to setup the LDAP connection in the standalone.xml file in WildFly for reference via JNDI in the application like we currently do. I have setup LDAP for authentication and that works but I do not know how to reference that connection for use in our application.

ci_ms
  • 65
  • 1
  • 8

1 Answers1

1

In Wildfly you can use Naming Subsystem for binding a Ldap context, in particular External Context Federation binding type:

External Context Federation

Federation of external JNDI contexts, such as a LDAP context, are achieved by adding External Context bindings to the global bindings configuration, through the external-context XML element

For example:

<subsystem xmlns="urn:jboss:domain:naming:2.0">
    <bindings>
        <external-context name="java:global/federation/ldap/example" class="javax.naming.directory.InitialDirContext" module="org.jboss.as.naming" cache="true">
            <environment>
                <property name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory" />
                <property name="java.naming.provider.url" value="ldap://ldap.example.com:389" />
                <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>

Ref: WildFly 8 - Naming Subsystem Configuration

I hope this help.

Federico Sierra
  • 5,118
  • 2
  • 23
  • 36
  • Thanks for the response. This looks like it could work. However, when I deploy to WildFly it comes back with Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[518,137] Message: JBAS014724: Missing required attribute(s): module... Line 517 is the Line. What would i set for the module attribute? – ci_ms Dec 10 '14 at 19:47
  • 1
    @ci_ms The `module` attribute is needed on the `external-context` config, the documentation is wrong. The `jboss-as-naming_2_0.xsd`schema define ``. Try use `module="org.jboss.as.naming"`. – Federico Sierra Dec 10 '14 at 20:07