2010-02-18 103 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