【问题标题】:Use an existing KerberosTicket to Bind to Ldap and search for users attributes使用现有的 KerberosTicket 绑定到 Ldap 并搜索用户属性
【发布时间】:2009-03-26 19:46:53
【问题描述】:

在给定已转发到我的代码的现有 javax.security.auth.kerberos.KerberosTicket 的情况下,Java 是否有办法查询 Active Directory 中的用户属性?我知道我想使用 Ldap 进行搜索,但我对如何使用此 KerberosTicket 对象绑定到 ldap 感到困惑。目前我正在使用 Spring-Ldap 和 Spring-Security 与 Active Directory 通信并使用简单的身份验证凭据我可以绑定用户名和密码来验证我的用户并检索我的所有属性、角色等。但是在我通过的情况下来自该 Active Directory 服务器的 KerberosTicket 我现在知道如何绑定自己,因为我不知道该用户的密码。我目前没有从 LoginContext 调用 login() 来获取我的 KerberosTicket,它已作为加密的 java 对象转发到我的代码。

【问题讨论】:

    标签: java ldap kerberos


    【解决方案1】:

    在您的 LDAP 连接环境中,将 Context.SECURITY_AUTHENTICATION 设置为“GSSAPI”。然后在特权操作中创建 InitialLdapContext:

    InitialLdapContext 上下文; Subject.doAs(主题,新的 PrivilegedAction(){ 公共对象运行(){ 上下文 = 新 InitialLdapContext(env, null); } };

    您可以通过在 LoginContext 上调用 getSubject() 来获取主题变量。 env 是环境。您将不得不以某种方式捕获 NamingException。 请注意,要在较新的 Windows 版本上使用此功能,您必须设置注册表项,请参阅 http://java.sun.com/j2se/1.5.0/docs/guide/security/jgss/tutorials/Troubleshooting.html(搜索注册表)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-23
      • 1970-01-01
      • 1970-01-01
      • 2018-01-26
      • 2020-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多