Link to home
Start Free TrialLog in
Avatar of yechan
yechanFlag for United States of America

asked on

Trouble connecting to SQL Server

Hi Experts,

I have created a WCF service that is hosted on IIS.  I keep getting the following error message:

"Login failed for user ''. The user is not associated with a trusted SQL Server connection."

My connection string is as follows:
server=xxxxxx\yyyyyyyyy; Initial Catalog=IDPInfoPath; Integrated Security=SSPI; Trusted_Connection=yes

Server authentication has been set up as "Windows Authentication mode".  Unfortunately I can not chance it to "SQL Server and Windows Authentication mode".

On IIS, "Anonymous access" and "Integrated Windows authentication" both have been checked.  Under "Anonymous access", I have specified my domain account and password.

Finally, my web.config has been set up as follows:

<identity impersonate="true" userName="xxxxx\yyyyyy" password="zzzzz"/>
<authentication mode="None"/>

I am able to get to the SQL Server from SSMS with my windows credentials just fine.  

Any assistance would be greatly appreciated.
Avatar of yechan
yechan
Flag of United States of America image

ASKER

I have also tried the following in the web.config file

<authentication mode="Windows"/>
you need to give permission to the user on the database which should have connect permission
Avatar of yechan

ASKER

Hi,'

I have been set up as an admin on sql server.   I probably do not understand the security model as well as I should.  If I type in my domain account and password in the "Anonymjous access" section, doesn't the WCF or ASP.Net app run under that security context?

thanks
it all depends how sql security mode is settup if you said windows authentication then it will only user who has the right if you setup as mixmode then it will allows as sql user as well windows user
ASKER CERTIFIED SOLUTION
Avatar of san_spy
san_spy
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yechan

ASKER

Good morning,

I have entered my domain account in IIS.  My domain account has the ability to communicate with SQL Server.  When I use the same connection sttring in a Windows app, it works just fine.  I am thinking between entering my domian account into IIS and using impersonation in the web.config file, it would attempt to run SQL queries under my domain account and not some local aspnet account.
that should work. Let us know if that works..
Avatar of hariprasadrj
hariprasadrj

you may try assigning your credentials for the app pool, in that case the application would in that security context.