我正在开发第三方Java应用程序,我需要使用Active Directory对其用户进行身份validation。
此应用程序托pipe在RHEL 6.5上,并使用LDAP通过Windows Active Directory进行身份validation。 AD服务器已经build立,并且与早期版本的应用程序(已configuration为启用集成)工作正常。
对于较新的版本,供应商已经规划了一些步骤来修改/configuration应用程序文件以连接到AD服务器,并期望帮助我们进行身份validation。
应用程序的组件之一是CAS,它当前被configuration为使用数据库作为其身份validation处理程序。 当我们input凭据 – 用户名:abcd,密码:samplepswd,我们能够成功login。
由于业务需求是使用LDAP使用Active Directory进行身份validation,因此我们必须修改CAS属性文件。 根据产品供应商的说明,我们更改了以下属性以使用ldap –
authenticationHandler.type=ldap ldapSSLConfig.enabled=false ldapContextSource.url=ldap://sample.ADserver.example.net:389 ldapContextSource.userDn=abcd ldapContextSource.password=samplepswd ldapAuthenticationHandler.filter=uid=%u ldapAuthenticationHandler.searchBase=OU=DEF,OU=PQR,OU=XYZ,DC=ADserver,DC=example,DC=net
我们还需要对casAuthConfig xml文件进行以下属性的更改(因为不支持匿名search):1. anonymousReadOnly,value设置为false 2. java.naming.security.authentication,value设置为simple
有规定也可以使用SSL上的ldap,但目前我们没有使用。 但是,如果我们使用SSL,则必须对以下属性进行其他更改:
ldapSSLConfig.enabled=true ldapSSLConfig.trustStorePath=/home/dir1/subdir1/subdir2/keystorename.keystore ldapSSLConfig.trustStoreType=jceks
这些是在我们(客户端)完成的唯一configuration更改; 实际上只做了一些改变。 服务器(AD服务器)上除了另一个用户以外没有添加/修改任何内容,但是这对现有设置没有影响。
重新启动cas以反映更改后,我们会遇到错误的凭据错误,虽然input的值是正确的:
2015-09-16 12:12:30,558 INFO [com.emeter.cas.authentication.support.DelegatingAuthenticationHandler] - Authenticating credential using handler com.emeter.cas.adaptors.ldappwd.BindLdapAuthenticationHandler 2015-09-16 12:12:30,558 DEBUG [com.emeter.cas.authentication.support.DelegatingAuthenticationHandler] - credentials.getUsername() = abcd 2015-09-16 12:12:30,672 INFO [com.emeter.cas.adaptors.ldappwd.BindLdapAuthenticationHandler] - Search for cn=abcd returned 0 results. 2015-09-16 12:12:30,672 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - AuthenticationHandler: com.emeter.cas.authentication.support.DelegatingAuthenticationHandler failed to authenticate the user which provided the following credentials: [username: abcd] 2015-09-16 12:12:30,676 ERROR [org.jasig.cas.integration.restlet.TicketResource] - error.authentication.credentials.bad org.jasig.cas.ticket.TicketCreationException: error.authentication.credentials.bad at org.jasig.cas.CentralAuthenticationServiceImpl.createTicketGrantingTicket_aroundBody10(CentralAuthenticationServiceImpl.java:423)
任何人都可以帮助解决这个问题吗? 或者可能指向正确的方向? 任何帮助将不胜感激。
谢谢。
我在您的configuration中看到一些潜在的问题。
ldapContextSource.userDn和.password应该是AD中有权读取将要login到应用程序的所有用户帐户的帐户的凭证。 他们希望.userDn值实际上是一个LDAP DNstring(类似于.searchBase),但是对于Active Directory,您可以使用userPrincipalName(UPN)属性(通常为[email protected])。 所以错误的凭据错误可能只是你没有任何资格的用户名。 我总是更喜欢使用UPN进行LDAP集成,因为帐户可以在AD内移动,应用程序不关心(不像DN会改变)。
假设得出结论,你的.filter值也可能成为一个问题。 虽然uid属性在Active Directory中确实存在,但通常不会默认填充它。 如果您希望用户仅使用用户名login,则应将其更改为sAMAccountName。
当您开始启用基于SSL的LDAP(LDAPS)时,您需要在Java应用程序信任的域控制器上拥有一个TLS证书。 如果是自签名证书,则该证书需要进入其文档引用的密钥库。 如果它是从公共或内部PKI基础架构生成的证书,则应该为该基础架构添加CA证书链。 您还需要将LDAP服务器URI更改为ldap s ://和端口636(或3269进行全局编录search)。