Platform SDK: Active Directory, ADSI, and Directory Services

About Service Logon Accounts

When a Win32®-based service starts up, it logs on to the local computer. It can log on using one of the following:

The logon account determines the security identity of the service at run time, that is, the service's primary security context. And the security context determines the service's ability to access local and network resources. For example, a service running in the security context of a local user account would have no access to network resources. At the other extreme, a service running in the security context of the LocalSystem account on a Microsoft® Windows® 2000 domain controller, would have unrestricted access to Microsoft® Active Directory™. For a discussion of the tradeoffs between user accounts and LocalSystem, see Security Contexts and Active Directoyr.

Ultimately, administrators on the system where the service is installed have control over the service's logon account. For security reasons, many administrators will not allow you to install your service under the LocalSystem account (unless you can present convincing documentation why they should). This means that your service must be able to run under a domain user account. As a programmer, you can exercise some control over your service's logon account. Your service installation program specifies the service's logon account when it calls the CreateService function to install the service on a host computer. Your installation program can suggest a default logon account, but it should allow an administrator to specify the actual account.

Your installation program can also perform the following tasks relating to your service's logon account:

After a service is installed, there are maintenance tasks relating to your service's logon account. See Logon Account Maintenance Tasks.