Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
This is my connection string, which the web service (hosted in IIS) uses to connect to database

XML
<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

It will work if you use Windows Authentication, even remotely.
 
Share this answer
 
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>
 
Share this answer
 
v3
Comments
Frank__Q 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.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900