【问题标题】:Grails, Spring Security LDAP PluginGrails,Spring Security LDAP 插件
【发布时间】:2011-08-15 07:02:37
【问题描述】:

我正在尝试使 LDAP 插件正常工作。我只想要针对 Active Directory 的 LDAP 身份验证,但似乎我遗漏了一些东西。

配置

grails {
    plugins {
        springsecurity {


            userLookup.userDomainClassName = 'de.ac.dmf.security.User'
            userLookup.authorityJoinClassName = 'de.ac.dmf.security.UserRole'
            authority.className = 'de.ac.dmf.security.Role'

            ldap {
                context.managerDn = 'CN=dmf Systemuser,CN=Users,DC=dmf,DC=local'
                context.managerPassword = 'Password1'
                context.server = 'ldap://192.168.100.133:389/'
                authorities{
                    groupSearchBase ='OU=Groups'
                    groupSearchFilter = '(member={0})'
                    retrieveGroupRoles = false
                    retrieveDatabaseRoles = false
                    defaultRole = 'USER'
                    ignorePartialResultException = true
                }
                search{
                    base = 'CN=Users,DC=dmf,DC=local'
                    filter = '(sAMAccountName={0})'
                    searchSubtree = true

                }
                // mapper.userDetailsClass = 'user'
                // auth.hideUserNotFoundExceptions = false
                useRememberMe = false
            }
        }
    }
}

每次登录我都会得到这个异常

2011-04-29 08:49:09,129 [http-8080-1] DEBUG springsecurity.RequestHolderAuthenticationFilter  - Authentication request failed: org.springframework.security.authentication.AuthenticationServiceException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001E4, problem 2001 (NO_OBJECT), data 0, best match of:
    'CN=Users,DC=dmf,DC=local'; remaining name 'CN=Users,DC=dmf,DC=local'

我尝试对我的 AD 中的哪个用户进行身份验证并不重要。是不是我的配置不对?

我正在使用

  • Grails 1.3.7
  • spring-security-core 1.1.2
  • spring-security-ldap 1.04

【问题讨论】:

  • 我的问题是第二个 LDAP 模板已初始化。删除后,我的登录问题就解决了。

标签: java grails groovy ldap spring-security


【解决方案1】:

您确定您的基本配置吗?看起来OU=Users 可以代替CN=Users 工作。解决这个问题的最简单方法是使用广告资源管理器 (http://technet.microsoft.com/de-de/sysinternals/bb963907) 之类的工具,连接到您的广告,浏览到用户并查看路径给用户...

【讨论】:

  • 嗨 Ralf,我已经验证了我的用户的路径。它只是一台基本机器,没有对此进行任何配置,并且在我的测试用例中基本是正确的。
  • AD 默认有一个 CN=Users,这在第一次遇到时是相当令人惊讶的。
【解决方案2】:

尝试使用:

filter = '(&(sAMAccountName={0})(objectclass=user))'

这适用于我们的广告。

【讨论】:

  • 应该不需要添加对象类,因为我们知道 sAMAccountname 在 AD 域中是全局唯一的)。
  • 它没有解决我的问题。我仍然无法针对 AD 域进行身份验证。
【解决方案3】:

您缺少提供者名单。

grails.plugins.springsecurity.providerNames = ['ldapAuthProvider',
    'anonymousAuthenticationProvider',
    'rememberMeAuthenticationProvider']

【讨论】:

    猜你喜欢
    • 2014-04-01
    • 2016-06-29
    • 2016-04-13
    • 2015-06-11
    • 2015-05-04
    • 2014-01-05
    • 2016-05-24
    • 2011-09-23
    • 2015-10-06
    相关资源
    最近更新 更多