![](/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.