2014-02-18 82 views
0

当尝试使用LDAP身份验证找到使用AD身份验证的用户时,我在grails中遇到错误。这是代码我从Grails的侧面具有:LDAP身份验证错误

@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(目录:“用户”,过滤器: “(的UserPrincipalName = $ {用户名})”)

示出此错误消息:

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

根据文档此错误表明,一个525错误意味着一个无效的用户,但我已经使用LDAP Explorer工具进行了测试,并且使用相同的详细信息连接到用户。

在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

Doe任何人有任何想法,我做错了什么?

回答

0

您的错误出现在app-config LDAP设置中。

ldap.directories.user.userDn设置已被填充的容器,当你在ldap.directories.user.base指定的相同。

但是这应该是用户对象正在执行搜索的DN,一起ldap.directories.user.userDn = CN = myAppUser,OU =员工,DC =技能,DC线的东西=当地

525错误意味着用户没有找到但在这种情况下涉及到用户登录,而不是您正在搜索的用户。