LDAP身份验证错误

时间:2014-02-18 15:26:42

标签: java spring grails active-directory ldap

尝试使用LDAP身份验证查找使用AD身份验证的用户时,我在grails中收到错误。这是我在grails方面的代码:

@Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        ArrayList<String> roles=new ArrayList<String>(2);
        roles.add("ROLE_USER");
        try {
            GldapoSchemaClassForUser.findAll( directory: "user", filter: "(userPrincipalName=${username})" ).each{ user ->
            def userName = user.cn
            user.memberOf.each{ groupListing ->
            String groupName=groupListing.substring(3, groupListing.indexOf(','));
            if (groupName.equals("Admin")) {
                roles.add("ROLE_ADMIN");
            } else if (groupName.equals("User")) {
                // Do nothing
            }
        } catch (Throwable e) {
            System.err.println(e.getMessage())
        }
        return new User(username)
    }

当它尝试访问上面的这一行时,它会遇到catch块:

  

GldapoSchemaClassForUser.findAll(目录:“user”,过滤器:   “(userPrincipalName = $ {username})”)

显示以下错误消息:

  

org.springframework.ldap.AuthenticationException:[LDAP:错误代码49    - 80090308:LdapErr:DSID-0C090334,评论:AcceptSecurityContext错误,数据525,vece

根据文档,此错误表明525错误表示用户无效,但我已使用LDAP资源管理器工具进行测试,并且使用相同的详细信息连接到用户。

在app-config文件中,我有以下ldap设置:

  • ldap.directories.user.url = LDAP://sbs.testsbs.local
  • ldap.directories.user.base = OU =人员,DC =技能,DC =本地
  • ldap.directories.user.userDn = OU =人员,DC =技能,DC =本地
  • ldap.directories.user.password = Pa55w0rd

有没有人对我做错了什么有任何想法?

1 个答案:

答案 0 :(得分:0)

您的错误位于app-config LDAP设置中。

ldap.directories.user.userDn 设置已使用容器填充,与 ldap.directories.user.base 中指定的容器相同。

然而,这应该是执行搜索的用户对象的DN,类似于 ldap.directories.user.userDn = CN = myAppUser,OU = staff, DC =技能,DC =本地

525错误表示用户未找到但在这种情况下属于登录的用户,而不是您要搜索的用户。