简体   繁体   English

WildFly LDAP连接JNDI

[英]WildFly LDAP Connection JNDI

We are in the process of moving from Glassfish to WildFly. 我们正在从Glassfish迁移到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. 在Glassfish中,我们设置了LDAP服务器并将其用于身份验证,并且还在应用程序中通过JNDI为我们引用了它,以进行诸如搜索用户等之类的事情。我想知道是否有一种方法可以独立设置LDAP连接。像我们目前所做的那样,在WildFly中使用xml文件通过JNDI在应用程序中进行引用。 I have setup LDAP for authentication and that works but I do not know how to reference that connection for use in our application. 我已经设置了用于身份验证的LDAP,并且可以使用,但是我不知道如何引用该连接以在我们的应用程序中使用。

In Wildfly you can use Naming Subsystem for binding a Ldap context, in particular External Context Federation binding type: 在Wildfly中,您可以使用命名子系统来绑定Ldap上下文,特别是外部上下文联合绑定类型:

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 外部JNDI上下文(例如LDAP上下文)的联合是通过使用external-context XML元素将外部上下文绑定添加到全局绑定配置中来实现的

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 参考: WildFly 8-命名子系统配置

I hope this help. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM