【发布时间】:2017-02-02 09:58:11
【问题描述】:
我使用org.apache.shiro.realm.ldap.DefaultLdapRealm 对LDAP 进行身份验证(以ldap://ldap.forumsys.com:389/dc=example,dc=com 为例)。
但是,当我尝试检查角色时,它总是失败。原来 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 的代码副本。
每个人如果想在使用 Shiro 的组中使用 LDAP,是否必须编写自定义领域?
DefaultLdapRealm 不能获取配置组搜索过滤器但不需要额外代码的属性(例如用于登录的 userDNTemplate)?
这样的领域是否已经存在于 maven 依赖项中?
【问题讨论】: