Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用SID从操作系统获取WindowsIdentification_C#_Windows_Windows Identity - Fatal编程技术网

C# 使用SID从操作系统获取WindowsIdentification

C# 使用SID从操作系统获取WindowsIdentification,c#,windows,windows-identity,C#,Windows,Windows Identity,我正在通过WCF将请求从机器A发送到机器B。 两台计算机上的域和用户相同。 在机器B中,使用给定的参数,我想为从机器a调用操作的用户创建一个WindowsIdentity 我知道有技术可以通过WCF基础设施做到这一点,但我的项目中没有启用这项技术。 所以我需要将OperationContext.Current.ServiceSecurityContext.WindowsIdentity.User.Value从机器A发送到机器B 我的问题是如何使用SID创建WindowsIdentity?或者我需

我正在通过WCF将请求从机器A发送到机器B。
两台计算机上的域和用户相同。
在机器B中,使用给定的参数,我想为从机器a调用操作的用户创建一个
WindowsIdentity

我知道有技术可以通过WCF基础设施做到这一点,但我的项目中没有启用这项技术。
所以我需要将
OperationContext.Current.ServiceSecurityContext.WindowsIdentity.User.Value
从机器A发送到机器B

我的问题是如何使用SID创建
WindowsIdentity
?或者我需要发送不同的参数吗

笔记: 我试着这样做:

PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "My_Domain");
GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, "userSID");
当然,使用正确的参数,然后迭代所有GRP.GetMembers(true)以查找我的-但它不在那里

更新: 用户是:
DOMAIN\u NT/MyUser123
->如果我将其更改为
MyUser123@DOMAIN_NT
并创建
WindowsIdentity
identity=new WindowsIdentity(“MyUser123@DOMAIN_NT");-它可以工作,但这是一种丑陋的方式