2010-02-18 99 views
0

我正在开发一个使用Grails并使用Grails LDAP作为身份验证机制的Web应用程序。但是,我总是得到以下错误:Grails LDAP身份验证失败

{Error 500: Cannot pass null or empty values to constructor Servlet: default URI: /ldap-app/j_spring_security_check Exception Message: Cannot pass null or empty values to constructor Caused by: Cannot pass null or empty values to constructor Class: GrailsAuthenticationProcessingFilter }

我SecurityConfig.groovy文件是:

security { 
    // see DefaultSecurityConfig.groovy for all settable/overridable properties 
    active = true 
    loginUserDomainClass = "User" 
    authorityDomainClass = "Role" 
    requestMapClass = "Requestmap" 

    useLdap = true 
    ldapRetrieveDatabaseRoles = false 
    ldapRetrieveGroupRoles = false 
    ldapServer = 'ldap://worf-mi.dapc.kao.au:389' 
    ldapManagerDn = 'CN=sa-ldap-its,OU=Unix Servers for Kerberos,OU=Information Technology Services,OU=Special Accounts,DC=nexus,DC=dpac,DC=cn' 
    ldapManagerPassword = 'Asdf1234' 
    ldapSearchBase = 'OU=People,DC=nexus,DC=dpac,DC=cn' 
    ldapSearchFilter = '(&(cn={0})(objectClass=user))' 
} 

回答

0

我有同样的问题,并找到了解决办法。 发生此错误,因为Acegi-Plugin尝试将Ldap用户密码存储到用户对象中。 实际上,根据LDAP服务器的设置,不允许检索密码,因此会为错误消息所告知的构造函数提供一个空值。

我发现的修复并不是很好,但有助于启动和运行插件。您必须更改以下文件中的一个字段: 〜/ .grails // projects // plugins/acegi-0.5.3/src/java/org/codehaus/groovy/grails/plugins/springsecurity/GrailsUserImpl.java 或在Windows上: C:/用户// // Grails的项目//插件/ Acegi的-0.5.3/src目录/ JAVA /组织/ Codehaus的/常规/ Grails的/插件/ springsecurity/GrailsUserImpl.java

构造GrailsUserImpl ()具有以下机构:

super(username, password, enabled, accountNonExpired, 
credentialsNonExpired, accountNonLocked, authorities); 

必须被更改为:

super(username, "", enabled, accountNonExpired, 
credentialsNonExpired, accountNonLocked, authorities); 

不幸的是,这必须为每个开发者客户端和每个新项目完成。但是它最终得到了ldap认证。

正如我读他们正在研究这个错误,并尝试修复它的插件版本0.6。

希望我能帮上忙。

BR, 添

1

我有同样的问题,阅读上面的解决方案,并没有别的东西。我只是将用户表中的密码从NULL切换到“'(空字符串),而不是修改GrailsUserImpl.java。由于密码不用于LDAP的emptry串将被发送(而不是NULL值),其具有作为

super(username, "", enabled, accountNonExpired, 
credentialsNonExpired, accountNonLocked, authorities); 

相同的效果,但它不影响源代码。这对我的项目有效,希望它也能帮上忙。

史蒂芬

0

只需添加 “ldapUsePassword =假” 在securityconfig文件:

Setting ldapUsePassword to false is important too. What we’re telling the Acegi plugin is not to extract the users password from Active Directory. If you don’t set this to false, you’ll get a lovely exception which isn’t particularly useful, java.lang.IllegalArgumentException: Cannot pass null or empty values to constructor. What this is trying to tell you is that the users password is null, which is correct since the default setting for the Acegi plugin is to try to extract the users password from Active Directory, and we haven’t told Acegi what attribute Active Directory stores the password in. By setting ldapUsePassword to false, the plugin provides a bogus password for the user details, and we’re able to proceed without incident