Published on ThoughtShapes (http://thoughtshapes.com) © ThoughtShapes, Inc.

Windows Vista Limited User Account Operation

By Rjae Easton
Created 10/10/2007 - 1:02am

Windows Vista introduces several security improvements paving the way for limited user account operation versus the de facto practice of privileged user account operation. In this post we look at what the two modes of operation mean to a developer and how to do some common tasks under LUA operation.

Overview

Why should I operate under a limited user account (LUA)?

Why should I operate under a privileged user account?

What is the state of support for limited user account operation?

This is a deep, multi-faceted topic. I do not take it lightly by summarizing the above. There are many, many considerations including IIS Application Pool identity, Windows service identity, SQL Server identity just to name a few. Full coverage of the master topic is at least a book of material. Better to point out a few tips that developers “trying out” limited user account operation will find useful.

Operation

What follows is a few tips for common development scenarios. You may extend the basic concepts to just about any situation.

Service Control

Months after I installed Windows Vista there was one remaining thorn in my side: service control. I tend to keep most services stopped until they are needed. For example, SQL Server is normally not running on my machine unless I need it. Prior to Windows Vista I could issue a command such as runas /user:root "cmd /k net start mssqlserver".

This stopped working in Windows Vista. The only workaround I came up with was to launch Computer Management as administrator, navigate to services, find the service I want to start. It worked but I knew it was not optimal. Several weeks ago a colleague [1] challenged me during a presentation when I said this was the only way. He clued me into a better way: enter SC.

  1. Open a command prompt (Run as administrator)
  2. Enter your SC command e.g. sc start mssqlserver

The general principle here is to open a command prompt with elevated privileges. Many commands requiring temporary elevation can be executed this way.

Visual Studio 2005

It was not easy, but after a hotfix and a rain dance Visual Studio 2005 handles itself just fine under limited user account operation.

Installation

Back in March this is what I had to do for Visual Studio 2005 to run under limited user account. When you read this post things may have changed; check MSDN [2] for the latest information.

  1. Install Visual Studio 2005
  2. Install Visual Studio 2005 Service Pack 1 Update for Windows Vista [3]

Debugging

It would be nice I guess for Visual Studio 2005 to provide an option for privilege elevation from within an instance running under limited user account. That is not available and I do not see it being developed. If you want to perform a privileged operation such as attaching a debugger to a process then start a new instance of Visual Studio 2005 (Run as administrator).

The general principle here is to open an application with elevated privileges so that you may perform specific tasks.

Filtered Token

Back in the day when we lifted void ** and used imported smart pointers, there was a lot of low-level coding around logon tokens. Early Win32 API documentation coined the terms process token and thread token. If you wanted to temporarily elevate your privilege e.g. on an ASP worker thread, you would create a logon handle and impersonate the thread token using that handle. Trust me, this all worked very nicely.

The story today is similar but with some cool foresight. Under Windows Vista members of the Administrator group use filtered process tokens. This means that even those accounts cannot perform privileged operations without user interaction. So even if you think all this LUA stuff is silly, you are still protected under Windows Vista.


Source URL:
http://thoughtshapes.com/node/65