I have a SID of a user account, and I want the SIDs of the groups it belongs to. (C#)
Posted
by JCCyC
on Stack Overflow
See other posts from Stack Overflow
or by JCCyC
Published on 2010-03-22T19:44:45Z
Indexed on
2010/03/22
19:51 UTC
Read the original article
Hit count: 259
This has to be obtained from a remote machine. The following query works not for SIDs, but for group and account names.
"SELECT GroupComponent FROM Win32_GroupUser WHERE PartComponent = \"Win32_UserAccount.Domain='" + accountDomain + "',Name='" + accountName + "'\""
The Win32_Group objects it returns come in the forms of strings, and they only have domain and name (even though Win32_Group has a SID property).
I have this sinking feeling I'll have to:
- Turn the SID into an account name by querying Win32_SID;
- Perform the query above;
- Turn each of the resulting group names into SIDs by querying Win32_Group.
PLEASE tell me there's a better way.
© Stack Overflow or respective owner