Reputation: 4607
I want to create a C++ program with limited privileges. I made some research on the internet and found out that I have to create a token and then use the AdjustTokenPrivileges() method to alter its privileges.
However, I didn't quite understand how this is to be done. Can someone please provide me with an example of how to create a token and disable its privileges? Thanks :)
Upvotes: 1
Views: 492
Reputation: 4224
Did you check out the example at Executing Privileged Operations Using C++ ? Seems like you just need to figure out which tokens are which after using the GetTokenInformation() function, and then disable some of them.
[EDIT] Explaining in a bit more detail.
Here are specifics about the TOKEN_PRIVILEDGES structure. For each member of Priviledges array, you can look up the name of the priviledge using LookupPrivilegeName.
Here is a list of Priviledge names and descriptions.
After you know what priviledge it is (i.e. by checking the name), you can set the Attributes of the Priviledges[i] member to one of
In your case, I recon it will be mostly the third.
Upvotes: 1