get nt sid when user logs onto an asp page
I'm wanting to grab a users NT SID when they access my page for secuity purposes..
this sort of thing
S-1-5-21-1614280859-2041256729-1847403543-2152
I can't seem to figure this out..
I saw a post that directed the OP to a book, but I don't want to buy a whole book just to do one thing. In that post, they mentioned that the ObjectSID was part of the security token, but I have no idea how to get to this..
Any help would be appreciated.
Thanks..
Solution thanks to Simon:
IntPtr logonToken = WindowsIdentity.GetCurrent().Token;
WindowsIdentity window开发者_运维百科sId = new WindowsIdentity(logonToken);
string strSID = windowsId.User.ToString();
Looks like you want the WindowsIdentity class.
You can get the current identity with WindowsIdentity.GetCurrent()
, and then read the User property to get the SecurityIdentifier for that user.
精彩评论