开发者

Create a security identifier for the current domain

I want to create a security identifier for AccountDomainUsersSid. The problem is that I can't figure out how to get the sid for the current domain (i.e. the domain that开发者_高级运维 the current user is logged in to).

var sid = new SecurityIdentifier(WellKnownSidType.AccountDomainUsersSid, /* what do I write here? */);


SecurityIdentifier has an AccountDomainSid property.

The User property of the WindowsIdentity is a SecurityIdentifier.

WindowsIdentity has the GetCurrent() method that reutrns the current WindowsIdentity.

So this will write out the AccountDomainSid of the Current user

   WindowsIdentity id = WindowsIdentity.GetCurrent();
   Console.WriteLine(id.User.AccountDomainSid);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜