I read a list of SIDs from the registry, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
.
How would one resolve the display username (e.g. DOMAIN\user
, BUILT-IN\user
) given the SID string in C#?
I read a list of SIDs from the registry, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
.
How would one resolve the display username (e.g. DOMAIN\user
, BUILT-IN\user
) given the SID string in C#?
The Win32 API function
LookupAccountSid()
is used to find the name that corresponds to a SID.LookupAccountSid()
has the following signature:MSDN Ref.
Here's the P/Invoke reference (with sample code): http://www.pinvoke.net/default.aspx/advapi32.LookupAccountSid
Just found it on the pinvoke.net.
Alternative Managed API: Available in .Net 2.0: