2016-09-24 53 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依賴中?

回答

相關問題