[Last Call] Learn how to a build a cloud-first strategyRegister Now


problem connecting to sql from wcf service running in IIS 6

Posted on 2012-08-13
Medium Priority
Last Modified: 2012-08-14
I have a WCF service running in IIS 6.  
In IIS it is set to “Enable anonymous access”.  I set the User name to “domain\useraccount” and set the password.
In the web config in the <system.web> section I have <identity impersonate="true"/>

This is the connection string: “Server=ANTWRISE\BCW;Database=DBNAME; Trusted_Connection=True;”

When I attempt to connect to the database I get this error:
Cannot open database "DBNAME" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Question by:tj_ntwnt
1 Comment

Accepted Solution

tj_ntwnt earned 0 total points
ID: 38292355
I found the solution to this problem.  
I created a new Application Pool and set the user to a domain user.  
Made sure that the user could log in as a service:  To do this:
   Open the server's local security policy (start>run>secpol.msc), expand local polices and  browse to User Rights assignment. Once in User Rights Assignment, open up the “Log on as Service“ right. Any account or group in this list will be able to logon as a service. So, click Add User or Group, and add the user.Once the right is granted will need to reboot  server. Security settings are applied during the startup phase of any NT/2000/XP/2003 machine.
Added the user to the local group IIS_WPG.  To do this:  
  Go into computer management Start-> (right click on My Computer) > Manage.  Chose "Local Users and Grroups" open Groups and select IIS_WPG.  Add the user to it.

After this is done go under the Default Web Site and right click on the virtual directory that is running the WCF service and change the "Application Pool" to the new one that is running as a domain user.

That fixed the problem.

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question