Compartir a través de


How to: Access SQL Server as a Local User

By default, when an ASP.NET application runs, the application runs in the context of a special local user account named ASPNET (in Microsoft Windows 2000 and Microsoft Windows XP) or NETWORK SERVICE (in Microsoft Windows Server 2003). This user account has sufficient user rights on the Web server to allow the application to run.

If Microsoft SQL Server and the Web server are on the same computer, you can define the ASPNET or NETWORK SERVICE user account as a local user account on the computer running SQL Server.

The advantage of this method is that it is secure, because the Web application runs within a limited security context. Using a single user name with SQL Server is also efficient because it enables SQL Server to take advantage of connection pooling, which further enhances the scalability of the application.

To grant SQL Server user rights to the ASPNET or NETWORK SERVICE user account

  1. In Windows, click Start, point to Programs, point to Microsoft SQL Server, and then click Enterprise Manager.

  2. Expand the node for the server, and then expand the node for the database for which you want to grant user rights.

  3. Right-click Users, and then click New Database User.

  4. In the Database User Properties dialog box, in the Login name box, enter computername**\ASPNET** or NT AUTHORITY\NETWORK SERVICE, and then click OK.