Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain logged on user SID rather than elevated user

How would I obtain the logged on user SID in an elevated .NET application?

I have tried WindowsIdentity.GetCurrent() which of course returns the administrator that elevated the process. From what I can see I may need to use native methods to do this, could anyone provide a more elegant way?

like image 690
Luke Avatar asked Jan 18 '26 17:01

Luke


1 Answers

Investigating Greg's suggestion of using the registry:

I have found the following key which appears reliable in providing the currently logged on user's information. This key includes information such as display name and SID. This information is stored under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"

This information is accurate on Windows 8. I have checked Windows 7 and much less information is included, eg: there is no logged on user SID.

like image 139
Luke Avatar answered Jan 20 '26 10:01

Luke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!