Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
This is my connection string, which the web service (hosted in IIS) uses to connect to database
 
<add name="AdventureWorksEntities"connectionString="metadata=.\AdventureWorks.csdl|.\AdventureWorks.ssdl|.\AdventureWorks.msl;
provider=System.Data.SqlClient;provider connection string='Data Source=TestMachine;Initial Catalog=AdventureWorks;
Integrated Security=True;Connection Timeout=60;multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />
 
When I try to access the site I am getting an exception: Login Failed for user MyDomain\TestMachine$.
 
Why is IIS trying to use TestMachine to connect and not my user account (e.g MyDomain\TestUser) ? How do I specify it to use the context of the user that made the request ?
Posted 30-Oct-12 13:54pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You have to turn on Impersonation in the web.config. This will make IIS use your windows account when connecting to SQL
 

<system.web>
<identity impersonate="true" />
....</system.web>
  Permalink  
v3
Comments
Frank__Q at 31-Oct-12 12:52pm
   
If I do that then I cannot access the site remotely. Accessing the site from local IIS server machine will work but not remotely.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It will work if you use Windows Authentication, even remotely.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.150302.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100