problem connecting to sql from wcf service running in IIS 6

Posted on 2012-08-13
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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now