2016-09-24 55 views
0

我正在使用org.apache.shiro.realm.ldap.DefaultLdapRealm对LDAP进行身份验证(使用ldap://ldap.forumsys.com:389/dc=example,dc=com作为示例)。有没有一种通用的方法来搜索带有Shiro的LDAP组?

但是,当我尝试检查角色时,它总是失败。事实证明,当搜索组时,DefaultLdapRealm返回null。

/** 
* Method that should be implemented by subclasses to build an 
* {@link AuthorizationInfo} object by querying the LDAP context for the 
* specified principal.</p> 
* 
* @param principals   the principals of the Subject whose AuthenticationInfo should be queried from the LDAP server. 
* @param ldapContextFactory factory used to retrieve LDAP connections. 
* @return an {@link AuthorizationInfo} instance containing information retrieved from the LDAP server. 
* @throws NamingException if any LDAP errors occur during the search. 
*/ 
protected AuthorizationInfo queryForAuthorizationInfo(PrincipalCollection principals, 
                 LdapContextFactory ldapContextFactory) throws NamingException { 
    return null; 
} 

有一个similar question from 2012,但是,它看起来像从ActiveDirectoryRealm代码的副本。

是否大家谁想要使用LDAP与组使用Shiro必须写一个自定义Realm?

DefaultLdapRealm是否能够为组配置搜索过滤器的属性,但不需要额外的代码(如userDNTemplate用于登录)?

这样一个领域是否已经存在于maven依赖中?

回答

相关问题