Jon
Jon

Reputation: 81

How to check the system rights of a user in C++

I've only been able to find an answer to the need for AdministatorRights here, and so I ask for help on this one. I hope I didn't miss an answer elsewhere, I truly apologize if I did.

Anyhow, I'm trying to write a simple program to search for the rights of the user.

I planned to iterate through the list and return the rights of the user, but I hit a road bump in that there is no method, as far as I see, to check if a user has the given privilege. I've been able to find information on attempting to change the status of the user rights, but not a simple call to see if they are enabled or disabled. Does anyone know a way around this method? I'm a bit stuck in how to achieve this, any help is greatly appreciated!

Thanks!

Upvotes: 3

Views: 2269

Answers (2)

Florian Winter
Florian Winter

Reputation: 5279

You can use LsaEnumerateAccountRights, but it only seems to report what rights are assigned specifically to that account and does not include the rights that are conveyed via group membership.

Upvotes: 0

Harry Johnston
Harry Johnston

Reputation: 36318

Just use GetTokenInformation with the TokenPrivileges option.

You can use OpenProcessToken or OpenThreadToken to get a handle to the access token you want to query.

Upvotes: 2

Related Questions