使用 JBoss 7 进行 LDAP 身份验证 [英] LDAP authentication with JBoss 7

查看:30
本文介绍了使用 JBoss 7 进行 LDAP 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 JBoss 7 服务器开发一个简单的 Java Web 应用程序,以启用从用户输入的用户名/密码登录并使用 ldap 进行身份验证.

I want to develop a simple java web application with JBoss 7 server to enable login from username/password entered by the user and authenticate with ldap.

这就是我在 web.xml 中写的放在 WEB-INF/中的内容

So this is what i wrote in web.xml placed in WEB-INF/

 <login-config>
     <auth-method>BASIC</auth-method>
     <realm-name>Enter user name and password</realm-name>
 </login-config>

然后在同一文件夹中添加 jboss-web.xml

then added jboss-web.xml in same folder

 <?xml version="1.0" encoding="UTF-8"?>
 <jboss-web>
     <security-domain>java:/jaas/website-domain</security-domain>  
 </jboss-web>

然后我在standalone.xml中添加了网站域领域

Then I added the website-domain realm in standalone.xml

<security-domain name="website-domain" cache-type="default">
    <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://localhost:10389"/>
            <module-option name="bindDN" value="ou=people,dc=mycompany,dc=com" />
            <module-option name="bindCredential" value="shad"/>
            <module-option name="allowEmptyPasswords" value="false"/>
            <module-option name="Context.REFERRAL" value="follow"/>
            <module-option name="throwValidateError" value="true"/>
            <module-option name="allowEmptyPasswords" value="true"/>
        </login-module>
    </authentication>
</security-domain>

那么输入的用户名和密码将如何发送到这些模块?还是我必须编写自定义 JAAS 领域?他们有什么可行的例子你们可以分享给我吗?

So how the username and password entered will be sent to these modules ? Or do I have to write a custom JAAS realm ? Is their any working example you guys can share me??

推荐答案

您的 webapp 需要通过在 WEB-INF/jboss- 中添加一行来指向您的安全域 website-domainweb.xml

Your webapp needs to point to your security domain website-domain by adding a line in WEB-INF/jboss-web.xml

<security-domain flushOnSessionInvalidation="true">java:/jaas/website-domain</security-domain>

我相信在 Jboss 7 中你只需要指定 website-domain(没有 java:/jaas/ 前缀)

I believe in Jboss 7 you need to only specify website-domain (no java:/jaas/ prefix)

这篇关于使用 JBoss 7 进行 LDAP 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆