Hi Eric,
your advice helped me, I got my stuff running now, but, frankly spoken,
I don't like the Windows API here.
All I wanted to do is to check, whether the owner of a file is a local
administrator. To accomplish this, I do the following:
1. get owner as SID using GetNamedSecurityInfo()
2. convert owner SID to ownerString using LookupAccountSid()
3. create SID of local administrators group using
AllocateAndInitializeSid()
4. convert local administrators group SID to groupString using
LookupAccountSid()
5. get all groups as strings that the owner is member of using
NetUserGetLocalGroups(ownerString) and check all group names whether
one of the equals groupString
There is a lot to do and a lot to pay attention to: get ownerString in
unicode format because NetUserGetLocalGroups needs it, free all the
memory that was allocated for the names,...
This is crazy from my point of view. Why can't all this operate on
SIDs? This would make life easier and programs smaller:
1. get owner as SID (ownerSID)
2. create SID of local administrators group (adminGroupSID)
3. get all SIDs of groups that ownerSID is member of and check if one
of them is adminGroupSID
On unix systems, some equivalent task would be to check whether the
file owner is root. The code for this would be:
struct stat fileInfo;
stat(filename, &fileInfo);
f( 0 == fileInfo.st_uid ) printf("owner is root.\n");
Quite short and straightforward, isn't it? :-)
Anyway, thank you for helping!
Marc-Philip