![](/img/trans.png)
[英]Implementing LDAP authentication in grails with spring-security-core-ldap plugin?
[英]Grails LDAP authentication failed
我正在通过使用Grails并将Grails LDAP作为我的身份验证机制来开发Web应用程序。 但是,我总是得到以下错误:
{错误500:无法将空值或空值传递给构造函数Servlet:默认URI:/ ldap-app / j_spring_security_check异常消息:无法将空值或空值传递给构造函数原因:无法将空值或空值传递给构造函数类: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))'
}
我遇到了同样的问题,请阅读上面的解决方案,然后执行其他操作。 无需修改GrailsUserImpl.java,我只需将用户表中的密码从NULL切换为''(空字符串)。 由于LDAP不使用密码,因此将传输空字符串(而不是NULL值),其效果与
super(username, "", enabled, accountNonExpired,
credentialsNonExpired, accountNonLocked, authorities);
但它不会影响源代码。 这对我的项目很有用,希望对您有所帮助。
史蒂文
我有同样的问题,找到了解决方案。 发生此错误,因为Acegi插件试图将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/org/codehaus/groovy/grails/plugins/springsecurity/GrailsUserImpl.java
构造函数GrailsUserImpl()具有以下主体:
super(username, password, enabled, accountNonExpired,
credentialsNonExpired, accountNonLocked, authorities);
必须更改为:
super(username, "", enabled, accountNonExpired,
credentialsNonExpired, accountNonLocked, authorities);
不幸的是,这必须对每个开发人员-客户端和每个新项目都进行。.但是它使ldap auth最终运行。
当我阅读时,他们正在研究此错误,并尝试使用插件的0.6版进行修复。
希望我能帮上忙。
br,蒂姆
只需在您的securityconfig文件中添加“ ldapUsePassword = false”即可:
将ldapUsePassword设置为false也很重要。 我们告诉Acegi插件的是不要从Active Directory中提取用户密码。 如果不将其设置为false,则会得到一个可爱的异常,该异常不是特别有用,java.lang.IllegalArgumentException:无法将null或空值传递给构造函数。 这是想告诉您的是用户密码为null,这是正确的,因为Acegi插件的默认设置是尝试从Active Directory中提取用户密码,而我们没有告诉Acegi Active Directory存储什么属性。密码。通过将ldapUsePassword设置为false,该插件为用户详细信息提供了伪造的密码,我们可以继续进行而不会发生任何事故
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.