- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试配置 apache shiro 以使用我们的 LDAP 服务器进行身份验证。我对 LDAP 不是很熟悉,所以请原谅我的无知!
在 shiro.ini 中使用以下选项工作正常(用户已通过身份验证):
ldapRealm.userDnTemplate = uid={0},ou=users,dc=mycompany,dc=com
但是,我们公司有多个组织单位 (ou)。如何使 ou 参数采用多个值?我可以用这个吗
ldapRealm.userDnTemplate = uid={0},ou=*,dc=mycompany,dc=com
我只想尝试所有组织部门,直到登录成功。
添加具有不同 ou 的额外 LDAP 领域怎么样:
#ldapRealm1ldapRealm1 = org.apache.shiro.realm.ldap.JndiLdapRealmldapRealm1.userDnTemplate = uid={0},ou=users1,dc=mycompany,dc=comldapRealm1.contextFactory.url = ldap://test.com:389#ldapRealm2ldapRealm2 = org.apache.shiro.realm.ldap.JndiLdapRealmldapRealm2.userDnTemplate = uid={0},ou=users2,dc=mycompany,dc=comldapRealm2.contextFactory.url = ldap://test.com:389#ldapRealm3ldapRealm3 = org.apache.shiro.realm.ldap.JndiLdapRealmldapRealm3.userDnTemplate = uid={0},ou=users3,dc=mycompany,dc=comldapRealm3.contextFactory.url = ldap://test.com:389
这行得通吗?
此外,是否可以在登录页面中添加一个下拉列表,以允许用户选择其组织单位并将其作为参数传递给 ldapRealm ?我应该如何进行呢?
TIA,塞拉菲姆
最佳答案
多个领域都可以正常工作。您只需创建 AuthenticationToken 的子接口(interface),该接口(interface)还指定您要定位的组织单位。
然后,您可以创建 LdapRealm 的子类并更改supports() 方法以返回 true IFF AuthenticationToken 反射(reflect)目标组织单位。例如:
LdapAuthenticationToken extends AuthenticationToken {
String getOrganizationalUnit();
}
LdapUsernamePasswordToken extends UsernamePasswordToken
implements LdapAuthenticationToken {
private String organizationalUnit; //add getter/setter
}
MyLdapRealm extends LdapRealm {
private String organizationalUnit; //add getter/setter
@Override
public boolean supports(AuthenticationToken token) {
return token != null && token instanceof LdapAuthenticationToken &&
this.organizationalUnit.equals(
((LdapAuthenticationToken)token).getOrganizationalUnit());
}
@Override
protected AuthenticationInfo doGetAuthenticatinoInfo(AuthenticationToken token) {
LdapAuthenticationToken ldapToken = (LdapAuthenticationToken)token;
//get the OU here, and do whatever you want with it.
}
}
如果您有多个领域,请注意每个领域可能都有自己的 LDAP 连接池,这可能不如单个共享连接池高效。
如果您希望拥有单个连接池,则需要使用一个领域并根据 OrganizationalUnit 手动制定查询。 LdapAuthenticationToken 在这种情况下也会很有帮助。
关于java - Apache shiro LDAP 多个 OU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9273631/
我已经一遍又一遍地讨论如何让用户登录 Shiro,但似乎仍然缺少一个重要的部分:shiro 如何根据存储的用户名和密码验证给定的用户名和密码?我想到的最多的是 It is each Realm's r
Apache Shiro 文档暗示了一些用于捕获连续失败登录尝试(以及其他)的所需功能,但是,我找不到具体的文档。目前我可以执行 currentUser.login(token);使用无效密码无限次并
我想在下一个Web项目中使用Shiro,但是我不知道一种好的(如果不是最好的)策略来管理用户(shiro.ini中的[users])。 最好为每个注册成员创建Shiro用户吗? 还是创建一个Shiro
我有一个简单的网络项目。我想在这个项目中访问多个角色是一个 URL。 网址的 sihor.ini 部分 [urls] /login.xhtml = authc /logout = logout /ad
我正在使用 apache shiro。当我想知道用户是否有权限和角色时,我使用 SecutiryUtils.getSubject()。我想知道如何向主题添加更多信息,例如电子邮件、主键和我需要的任何其
1、Shiro认证过程 1、收集实体/凭据信息 复制代码 代码如下: //Example using most common scenario of usern
我正在尝试使用 Shiro 对 Tomcat 6 中运行的 servlet 进行身份验证。 我有以下 shiro.ini 文件: [main] ps = org.apache.shiro.authc.
Apache Shiro的配置主要分为四部分: 对象和属性的定义与配置 URL的过滤器配置 静态用户配置 静态角色配置 其中,由于用户、角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包
我正在使用 Spring MVC、Tiles 和 Shiro。 这是我的未授权Url 属性的配置方式: 我的期望是,当 MyAuthorizingRealm发现无效凭据,Shiro 将重定向到 /un
我正在使用 Apache Shiro 开发基于 EJB 的网络服务来管理用户访问权限。我添加了 freshly released我的 Maven 项目的 Apache Shiro 1.5.0 版使用新
我正在将现有应用程序从Grails 2.4.4升级到Grails 3.2.8。我正在尝试从grails shiro插件迁移到grails spring-security-shiro插件。除了访问已登录
我正在将我的应用程序从grails 2.4.4迁移到grails 3.2.9。 我正在尝试迁移到 compile 'org.grails.plugins:spring-security-shiro:3
在我包含 shiro-core-1.2.2 和 shiro-web-1.2.2 之前,我的 Maven Web 项目工作正常但是当我在 pom.xml 中包含此依赖项之后,我在执行时收到错误mvn t
我将 Apache Shiro 与 Spring 一起使用,并且仅使用 Spring 的 Java 配置。 (没有 XML)。下面是我的配置类的一部分: @Configuration public c
我能够使用 shiro.ini 和 spring 运行 shiro,但我想使用 shiro 注释,所以我尝试在没有 ini 文件的情况下使用 shiro-spring。但这让我很难受错误: org.a
1. 权限管理 1.1 什么是权限管理? 权限管理实现对用户访问系统的控制,按照安全规则或者安全策略,可以控制用户只能访问自己被授权的资源 权限管理包括用户身份认证和授权两部分,简称认证授权 1.2
我们经常会有用到,当A 用户在北京登录 ,然后A用户在天津再登录 ,要踢出北京登录的状态。如果用户在北京重新登录,那么又要踢出天津的用户,这样反复。 这样保证了一个帐号只能同时一个人使用。那么下面
有没有办法在 Shiro 中实现多因素身份验证?有人可以给我一个关于如何实现这一点的提示吗? 更多细节: 基本思想是,用户需要像往常一样使用用户名和密码登录,但在实际验证之前,用户还需要输入他作为 S
ini 文件就像 [main] authc.loginUrl = /login.html authc.successUrl = /index.html authc.usernameParam = j_
我了解 spring jsf 和 hibernate。我已经整合了它们并创建了我自己的框架。现在我想使用 Apache Shiro 将 session 管理添加到我的框架中。但我对 Apache Sh
我是一名优秀的程序员,十分优秀!