Glassfish Jaas Active Directory
-
30-09-2019 - |
题
我正在尝试使用Glassfish中的JAAS来处理Active Directory的Web应用程序中的身份验证和授权。首先,我编写了一些POJO程序,这些程序可以成功连接到我的广告并针对我设置的用户和组进行身份验证。因此,我相信我在Web应用程序中使用的用户名,密码和组是正确的。
我正在跟进 本教程 在Glassfish中设置一个领域,以处理我的WebApp中的身份验证和授权。我已经用我想要的数据修改了我的web.xml和sun-web.xml。
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>myapp</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>activedirectory</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>authorized</role-name>
</security-role>
<security-constraint>
<display-name>Security</display-name>
<web-resource-collection>
<web-resource-name>Secured</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>authorized</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
</web-app>
和我的sun-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
<context-root>/myapp</context-root>
<security-role-mapping>
<role-name>authorized</role-name>
<group-name>Test</group-name>
</security-role-mapping>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class java code.</description>
</property>
</jsp-config>
</sun-web-app>
我的领域
name: activedirectory
class name: com.sun.enterprise.security.auth.realm.ldap.LDAPRealm
JAAS context: ldapRealm
Directory: ldap://myADServersIPAddress:389
Base DN: DC=myAD,DC=com
search-filter (&(objectClass=user)(userPrincipalName=%s))
search-bind-password fakepasswordhere
group-search-filter (&(objectClass=group)(member=%d))
search-bind-dn DN=Administrator
登录时我在日志中收到的错误消息,并且失败是
Login failed: javax.security.auth.login.LoginException:
javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-
0C090290, comment: AcceptSecurityContext error, data 525, v893]
我对错误代码“数据525”进行了一些研究,显然这意味着用户名无效。我正在使用我知道有效的ID和密码,我知道是Sun-web.xml中定义的“测试”的成员。我已经尝试使用当前设置以及samaccountname form(domain username)的UserPrincipal格式(用户名@domain),没有运气。我还将搜索过滤器更改为“ seal-filter”,以使用samaccountname在userprincipalname所在的位置,并且使用两个组合也不起作用。有人有任何线索或建议吗?我觉得我已经完成了研究,而且我非常接近,但在这一点上很困难。谢谢您,如果有人真正花时间阅读所有这些内容!
解决方案
我实际上测试的可能是您的查找凭据,因为您是根据DN =管理员搜索的,对吗?您是否尝试过将其全部DN授予搜索范围DN的管理员帐户?通常默认情况下会 DN=Administrator, CN=Users, DC=myAD, DC=com
根据您上面的信息。
其他提示
我同意REW的观点 - 我的搜索键盘DN必须完全有资格获得搜索结合ID的工作。