Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top