November 18, 2004

Reducing Privileges in Windows

Michael has an interested article that has been published on MSDN talking about how to reduce an Administrator's privilege in Windows to reduce the access rights of a normal user in an Administrative context. In other words, if you have to do something while as Admin that doesn't need admin rights (such as read email or browse the web), you can reduce your privileges of that process accordingly. Still not as good as running as a normal user and elevating privileges as required with runas, but still a good thing none the less.

The code is rather simple; simply grab a restricted token with less privileges using SaferComputeTokenFromLevel() and then pass that token to the start up params in CreateProcessAsUser(). Of course there is one limit with this... this API was introduced in Windows XP and Windows Server 2003. As such, this won't work on Windows 2000.

Good stuff. Great article. Enjoy!

Posted by SilverStr at November 18, 2004 06:02 PM | TrackBack