windows - MIT Kerberos 无法在 MSLSA 缓存中找到 TGT

标签 windows active-directory kerberos

我正在努力开发一个使用 MIT Kerberos 进行身份验证的 Windows 应用程序。

如果用户使用域用户帐户登录 Windows,klist 显示他从 AD 获取了预期的票证,包括以下票证:

#1>     Client: jalf @ TESTREALM.COM
        Server: krbtgt/TESTREALM.COM @ TESTREALM.COM
        KerbTicket Encryption Type: RSADSI RC4-HMAC(NT)
        Ticket Flags 0x40e00000 -> forwardable renewable initial pre_authent
        Start Time: 1/12/2012 9:46:27 (local)
        End Time:   1/12/2012 19:46:27 (local)
        Renew Time: 1/19/2012 9:46:27 (local)
        Session Key Type: RSADSI RC4-HMAC(NT)

但是,当我们尝试在应用程序中使用此票证时,Kerberos 库似乎找不到该票证。

这是相关代码的简化版本:

// Open the MSLSA cache
krb5_cc_resolve(kcontext, "MSLSA:", &mslsa_ccache);
// Create a cursor for traversing the cache
krb5_cc_start_seq_get(kcontext, mslsa_ccache, &cursor);
// Check all the credentials in the cache
while (!(code = krb5_cc_next_cred(kcontext, mslsa_ccache, &cursor, &creds)))  {
    // Find the one with the INITIAL flag set
    if ( creds.ticket_flags & TKT_FLG_INITIAL ) {
        // ticket found
        krb5_free_cred_contents(kcontext, &creds);
        break;
    }
    krb5_free_cred_contents(kcontext, &creds);
}

krb5_cc_end_seq_get(kcontext, mslsa_ccache, &cursor);

但无论出于何种原因,我们都不会输入 //Ticket found 部分。 在调试器中运行代码,我可以看到它找到了 klist 显示的其他几张票证,但由于某种原因,它从未找到我们感兴趣的票证。

任何人都可以解释这种行为,或者如何解决它吗?天真地,我希望 klist 的输出与使用 krb5_cc_next_cred 迭代缓存的结果相匹配。

我对 Kerberos 比较陌生,并且从一位离职的同事那里继承了这段代码,因此我可能错过了一些重要的基本信息。

最佳答案

您可能无权访问 LSA 中的 session key 。只有SSPI可以访问。你可以试试这个

Cause 2: This exception is thrown when using native ticket cache on some Windows platforms. Microsoft has added a new feature in which they no longer export the session keys for Ticket-Granting Tickets (TGTs). As a result, the native TGT obtained on Windows has an "empty" session key and null EType. The effected platforms include: Windows Server 2003, Windows 2000 Server Service Pack 4 (SP4) and Windows XP SP2.

Solution 2: You need to update the Windows registry to disable this new feature. The registry key allowtgtsessionkey should be added--and set correctly--to allow session keys to be sent in the Kerberos Ticket-Granting Ticket.

On the Windows Server 2003 and Windows 2000 SP4, here is the required registry setting:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Kerberos\Parameters
Value Name: allowtgtsessionkey
Value Type: REG_DWORD
Value: 0x01  ( default is 0 )

By default, the value is 0; setting it to "0x01" allows a session key to be included in the TGT. Here is the location of the registry setting on Windows XP SP2:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\Kerberos\
Value Name: allowtgtsessionkey
Value Type: REG_DWORD
Value: 0x01

Java 的 GSS impl 在这里也失败了。这是 Oracle 推荐的。使用 MIT Kerberos 时您可能会遇到同样的问题。

此更改仅在重新启动后生效。

关于windows - MIT Kerberos 无法在 MSLSA 缓存中找到 TGT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8834640/

相关文章:

hadoop - "Delegation Token can be issued only with kerberos or web authentication"空闲后重启 spark context

java - 如何在 sqljdbc4.jar 中配置 Java Kerberos

c++ - WICConvertBitmapSource BGR 到 Gray 意外像素格式转换

c - 异常的原因是什么?

powershell - 使用 Powershell 映射主文件夹将其设置在 AD 中但不执行任何其他操作

c# - 如何在 C# Web 应用程序中查找用户的 Active Directory 显示名称?

windows - 批处理文件在 FOR 循环中处理带有特殊字符和引号的字符串

java - 无法使用 JCIFS 和 jai imageio 从联网的 Windows PC 读取 tiff 图像

powershell - Get-ADUser 错误 : Invalid enumeration context

java-8 - 使用 Java 8 S4U2Proxy - 需要一个很好的例子