Users are identified in Windows OS not by names, but by special security identifiers, or Security Identifier - SID. The solution to the problem of determining the SID of the selected user does not require the use of additional software and is carried out using standard system tools.
Call the main system menu by clicking the "Start" button and go to the "Run" dialog. Type regedit in the "Open" line and confirm the launch of the Registry Editor utility by clicking the OK button. Expand the branch
HKEY_LOCAL_MACHINE \ Software \ Microsoft \ WindowsNT \ CurrentVersion \ ProfileList
and find all User IDs (SIDs). Go to the ProfikeImagePath key and find the corresponding SID username value. Exit the Registry Editor utility.
The reverse operation, when the SID of the user is known and it is required to determine the name of his account, can be performed using the reg.exe command. In this case, the command syntax looks like:
reg query HKEY_LOCAL_MACHINE \ Software \ Microsoft \ WindowsNT \ CurrentVersion \ ProfileList \ ProfileImagePath.
Use the built-in GetSID utility to determine the unique identifier for the selected user. The command syntax looks like:
drive_name: > getsid
Usage: getsid \ server1 account \ server2 account.
An alternative method to programmatically obtain the SID of the desired user is to use the SecurityIdentifier class in the. NET Framework 2.0. In this case, the identifier can be displayed as a string, a byte array, or a combination of the WellKnownSidType and domain SID values. An additional condition for obtaining the desired result is a call to the WindowsIdentity class. The syntax for such a command looks like this:
using System. Security. Principal;
static void Main (string  args)
WindowsIdentity wid = Windowsidentity. GetCurrent ();
Console. WriteLine (wid. Name + SID is 0, wid. User. Value);
Console. Read ();
} } }.