【问题标题】:Grails LDAP authentication failedGrails LDAP 身份验证失败
【发布时间】:2010-02-18 04:04:19
【问题描述】:

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

{错误 500:无法将空值或空值传递给构造函数 小服务程序:默认 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))'
}

【问题讨论】:

    标签: security spring authentication grails ldap


    【解决方案1】:

    我遇到了同样的问题,阅读了上面的解决方案并做了其他事情。我没有修改 GrailsUserImpl.java,而是简单地将用户表中的密码从 NULL 切换为 ''(空字符串)。由于 LDAP 不使用密码,因此将传输空字符串(而不是 NULL 值),其效果与

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

    但它不影响源代码。这对我的项目有用,希望它也有帮助。

    史蒂文

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题并找到了解决方案。 发生此错误是因为 Acegi-Plugin 试图将 Ldap-users 密码存储到 User-object 中。 事实上,根据 LDAP 服务器的设置,不允许检索密码,因此向构造函数提供了一个空值,如错误消息所示。

      我发现的修复不是很好,但有助于启动和运行插件。您必须更改以下文件中的一个字段: ~/.grails//projects//plugins/acegi-0.5.3/src/java/org/codehaus/groovy/grails/plugins/springsecurity/GrailsUserImpl.java 或在窗户上: C:/Users//.grails//projects//plugins/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, 蒂姆

      【讨论】:

        【解决方案3】:

        只需在您的 securityconfig 文件中添加“ldapUsePassword = false”:

        将 ldapUsePassword 设置为 false 是 也很重要。我们要告诉 Acegi插件是不解压的 Active Directory 中的用户密码。 如果您不将此设置为 false,您将 得到一个可爱的例外 特别有用, java.lang.IllegalArgumentException: 不能将 null 或空值传递给 构造函数。这是试图做什么 告诉你的是用户密码是 null,这是正确的,因为 Acegi 插件的默认设置 是尝试提取用户 来自 Active Directory 的密码,我们 还没告诉Acegi什么属性 Active Directory 存储密码 在。通过将 ldapUsePassword 设置为 false,插件提供了一个假的 用户详细信息的密码,以及 我们能够顺利进行

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-08-20
          • 2020-04-14
          • 2015-04-19
          • 2016-02-05
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多