Alex Rivera | Logout

How can I get the SID of the current Windows account?

Asked 2008-10-30T18:27:47.153
32

I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don't want to go that route.

Apologies to everybody that answered in C# for not specifying it's C++. :-)

Edit
Report

1 Answer

11
ATL::CAccessToken accessToken;
ATL::CSid currentUserSid;
if (accessToken.GetProcessToken(TOKEN_READ | TOKEN_QUERY) &&
    accessToken.GetUser(&currentUserSid))
    return currentUserSid.Sid();
answered 2012-11-13T06:07:38.480

Your Answer