如何模拟WellKnownSidType? [英] How to impersonate a WellKnownSidType?

查看:78
本文介绍了如何模拟WellKnownSidType?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用以下方式模拟Windows帐户: http://msdn.microsoft.com/en-us/library/chf6fbt4. aspx

I know I can impersonate a windows account using: http://msdn.microsoft.com/en-us/library/chf6fbt4.aspx

但是我该如何模拟一个WellKnownSidType帐户?

But how do I go about impersonating a WellKnownSidType account?

SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
NTAccount account = sid.Translate(typeof(NTAccount)) as NTAccount;
if (account != null)
{
    //Impersonate here???
}

推荐答案

首先,除非您在本地服务"下运行,否则您将无法模拟网络服务"或本地服务"等内置帐户.帐户,据我所知只能由操作系统完成.

First off, you will not be able to impersonate built-in accounts like 'Network Service' or 'Local Service' unless you are running under the 'Local Service' account, which as far as I know can only be done by the OS.

以下帖子为上述问题提供了一种可能的解决方案(我没有尝试过,只是在我开始写自己的全部内容之前用Google搜索了它),但这看起来很合理.

The following post provides a possible solution to the point above (I did not try it, just googled it before I started writting all this my self), but it looks reasonable.

http://geek.hubkey.com /2008/02/impersonating-built-in-service-account.html

一旦运行在本地服务"帐户下,您只需要使用LogonUser(也显示在上面的链接中)来使用众所周知的SID的帐户名登录,然后模拟令牌.

Once are running under the 'Local Service' account, you simply need to use LogonUser (also shown in the link above) to Logon using the account name of the well known SID and then impersonate the token.

我看到上面的链接将"CMD.EXE"作为一项可以与桌面进行交互的服务运行,请注意,与桌面进行交互"功能已被弃用.

I see the link above runs 'CMD.EXE' as a service which can is allowed to interact with the desktop, note that the 'interact with desktop' functionality is being deprecated.

这篇关于如何模拟WellKnownSidType?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆