문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top