gpt4 book ai didi

windows - 为用户 (S4U) token 创建服务

转载 作者:可可西里 更新时间:2023-11-01 10:46:16 24 4
gpt4 key购买 nike

Windows 任务计划程序可以创建使用特定用户帐户运行的任务,而无需存储用户密码。他们称之为“S4U”,为用户服务。这应该像调度程序为当前用户创建这样的 token 一样工作,并可以使用它在该用户帐户下运行计划的进程。他们声称它无法使用该系统访问网络或加密资源。调度程序本身使用 SYSTEM 帐户运行以使其工作。这是一个 article that describes it .相关引述:

TASK_LOGON_S4U is yet another option that provides a more secure alternative. It takes advantage of a service for user (S4U) logon to run the task on behalf of the specified user, but without having to store the password. Since the Task Scheduler runs within the local system account, it can create a S4U logon session and receive a token that can not only be used for identification, but also for impersonation on the local computer. Normally a S4U token is only good for identification.

我需要在我的应用程序中使用此身份验证方案,但不能让任务计划程序执行此操作而需要我自己执行,因为我需要它用于任意数量的帐户。每当用户向我的应用程序注册任务时,任何后续任务都必须在同一用户下运行。但由于它们不能重叠,我需要自己进行序列化。

我找不到关于这个“S4U”的任何信息。我怎样才能在我的应用程序中实现它?首选 C#,但 WINAPI 和 C 也可以。

更新:这是我尝试过的方法,但它不起作用。

// The WindowsIdentity(string) constructor uses the new
// Kerberos S4U extension to get a logon for the user
// without a password.
WindowsIdentity wi = new WindowsIdentity(identity);
WindowsImpersonationContext wic = null;
try
{
wic = wi.Impersonate();
// Code to access network resources goes here.
}
catch()
{
// Ensure that an exception is not propagated higher in the call stack.
}
finally
{
// Make sure to remove the impersonation token
if( wic != null)
wic.Undo();
}

但我现在的印象是,你不能只说你想成为某个用户。甚至不作为系统。您需要以该用户身份登录,并且可以生成一些 token ,使您可以在以后再次成为该用户,而无需密码。所以这一定是一个两步的事情,首先我需要获取 token 并将其存储在磁盘上;稍后我可以使用该 token 来模拟。这些例子都没有解释这一点。

最佳答案

“计算机可能没有加入域”

S4U 需要访问 KDC。 S4U实际上是两个协议(protocol)。 S4U2Self 和 S4U2Proxy。它正在做的是使用 Kerberos 的附加功能来为用户获取服务票证,但是用于获取票证的帐户必须启用特殊委托(delegate)。 See here对于这个设置。

但是除非您真的让进程终止等,否则为什么不直接获取用户服务票证或 TGT?您的应用程序是本地应用程序还是对用户远程运行的服务?

任务调度程序需要去获得一个新的,因为服务票证不是永远有效的。或者在某些委托(delegate)方案中,用户没有将服务票证传递给应用程序服务器,然后 AS 通过 S4U2Self 去请求和服务票证,然后使用该服务票证通过 S4U2Proxy 请求第二个服务的票证。

关于windows - 为用户 (S4U) token 创建服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24123440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com