I have a collection of SID values and need to display if they are in a given group. I know I can do that with CheckTokenMembership, if I had a token handle. How do I get a token handle from an SID in Windows?
LookupAccountSid
to get the account for the SIDNetUserGetGroups
to get all groups this account is a member of.LookupAccountName
to get the SIDs of the group.EqualSid
function.You find appropriate old code one the old win32.mvps.org pages. Sadly the page is gone. But Wayback machine helps. Here a link to the old fksec samples
You find an easy to use sid class there. It also provides sid::MemberOf
and sid::Members
functions. The code isn't my style but it works.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments