简体   繁体   English

jboss与LDAP的集成

[英]jboss integration with LDAP

I have an application which currently uses JDBC to authenticate the users that login to the application. 我有一个当前使用JDBC验证登录到该应用程序的用户的应用程序。 But now I want that it should be able to use LDAP to login into my application. 但是现在我希望它应该能够使用LDAP登录到我的应用程序。 My boss wants me to integrate LDAP with JBOSS in order to achieve it. 我的老板要我将LDAP与JBOSS集成在一起以实现它。 I am new to LDAP and have no idea on what needs to be done. 我是LDAP新手,不知道需要做什么。 Can anybody suggest something ? 有人可以建议吗?

You can add a custom security domain in JBoss' standalone.xml. 您可以在JBoss的standalone.xml中添加自定义安全域 In this domain you can configure your LDAP settings. 在此域中,您可以配置LDAP设置。 See this for some details. 有关更多详细信息,请参见此内容。 The LDAP settings depend on the LDAP you are using, so there are no general working settings. LDAP设置取决于您使用的LDAP,因此没有常规的工作设置。

Here would be an example: 这是一个示例:

<subsystem xmlns="urn:jboss:domain:security:1.0">
<security-domains>
    <security-domain name="other" cache-type="default">
        <authentication>
            <login-module code="Disabled" flag="required"/>
        </authentication>
    </security-domain>
    <security-domain name="test_ldap_security_domain">
        <authentication>
            <login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required">
                <module-option name="java.naming.factory.initial" value="com.sun.jndi.ldap.LdapCtxFactory"/>
                <module-option name="java.naming.provider.url" value="ldap://10.10.10.10:389"/>
                <module-option name="bindDN" value="cn=abc,cn=Users,dc=mydomain,dc=com"/>
                <module-option name="bindCredential" value="Test@123"/>
                <module-option name="baseCtxDN" value="cn=Users,dc=mydomain,dc=com"/>
                <module-option name="baseFilter" value="(userPrincipalName={0})"/>
                <module-option name="rolesCtxDN" value="cn=Users,dc=mydomain,dc=com"/>
                <module-option name="roleFilter" value="(userPrincipalName={0})"/>
                <module-option name="roleAttributeID" value="memberOf"/>
                <module-option name="roleNameAttributeID" value="cn"/>
                <module-option name="roleAttributeIsDN" value="true"/>
                <module-option name="allowEmptyPasswords" value="false"/>
                <module-option name="Context.REFERRAL" value="follow"/>
                <module-option name="throwValidateError" value="true"/>
                <module-option name="searchScope" value="SUBTREE_SCOPE"/>
                <module-option name="allowEmptyPasswords" value="true"/>
            </login-module>
            <login-module code="org.jboss.security.auth.spi.RoleMappingLoginModule" flag="optional">
                <module-option name="rolesProperties" value="/home/userone/jboss-as-7.0.1.Final/standalone/configuration/test-roles.properties"/>
                <module-option name="replaceRole" value="false"/>
            </login-module>
        </authentication>
    </security-domain>
</security-domains>
</subsystem>

Depending on the type of application, you need some config in your app to make the app use this domain. 根据应用程序的类型,您需要在应用程序中进行一些配置,以使应用程序使用该域。

If you have a web application (.war) you need a jboss-web.xml: 如果您有Web应用程序(.war),则需要一个jboss-web.xml:

<jboss-web>
    <security-domain>java:/jaas/test_ldap_security_domain</security-domain>
</jboss-web>

You can now use standard JavaEE authentication/authorization mechanisms.Eg in the web.xml. 您现在可以使用标准的JavaEE身份验证/授权机制。例如,在web.xml中。

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

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