使用SPNEGO(Kerberos TGT)进行身份验证时更改LDAP属性

时间:2016-02-15 22:58:27

标签: java ldap kerberos spnego

因此,我成功地使用SPNEGO进行身份验证,并使用来自KDC的TGT获取主体名称。但是我一直坚持如何通过使用TGT令牌,DN(可分辨名称)和主要名称来更新LDAP中该用户的属性?

我正在看类似以下的例子:

private static void performJndiOperation(String[] args) {

// Set up environment for creating initial context
Hashtable env = new Hashtable(11);

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

// Must use fully qualified hostname
env.put(Context.PROVIDER_URL, "ldap://ldap.jnditutorial.org:389/o=JndiTutorial");

// Request the use of the "GSSAPI" SASL mechanism
// Authenticate by using already established Kerberos credentials
env.put(Context.SECURITY_AUTHENTICATION, "GSSAPI");

try {
    /* Create initial context */
    DirContext ctx = new InitialDirContext(env);

    // do something useful with ctx
    ...

    // Close the context when we're done
    ctx.close();
} catch (NamingException e) {
    e.printStackTrace();
}
}

但我得到了无效凭证的例外情况:

javax.naming.AuthenticationException: GSSAPI [Root exception is javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Invalid option setting in ticket request.)]]

请你知道我做错了什么吗? 非常感谢您的帮助

1 个答案:

答案 0 :(得分:0)

检查krb5.conf renewableproxiable并使用选项。它实际上应该解决你的问题。