1

I have installed a new web application that access a SQL Server database in a different server. I'm using Windows Authentication and get the error of:

Login Failed for user XXX

When I try to set identity impersonate="true" in the web.config file, it just throws an error

Login Failed for anonymous user

Also, I'm using forms authentication to validate users from my website and using a different application pool.

Update: connection string Basically like this:

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

Update:

My Virtual Directory has Anonymous Authentication and Windows Authentication enabled.

10
  • 2
    Please, show us your connection string! We can't read your screen (nor your mind)..... you need to help us help you¨
    – marc_s
    Mar 25, 2011 at 21:14
  • 2
    Does the account that IIS has been configured to use for your site to run under a network account (from Active Directory, not a local machine account) have security rights to the SQL Server DB. IIS defaults to using a local account to run under, which means there will not be a way to use Windows Authentication on the SQL Server login, because the SQL Server box won't have visibility to that account b/c it is local to the web server.
    – ben f.
    Mar 25, 2011 at 21:20
  • @marc_s: Basically like this: "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;" Mar 25, 2011 at 21:21
  • OK thanks - also: which user is the first error message referring to??
    – marc_s
    Mar 25, 2011 at 21:24
  • @ben_f: IIS is running using Network Service. Is there a way to impersonate the user currently logged in? Mar 25, 2011 at 21:25

2 Answers 2

3

Typically ASP.NET runs as an anonomous account. In order to access a remote SQL Server using integrated authentication (SSPI), you'll need to have a bit more "permenant" presence. Easy way would be to shift the app pool to use the NETWORK SERVICE built-in account. Slightly trickier would be to use a named account. On the SQL server side of the equation you will need to give the same account -- either matching user/pass or NETWORK SERVICE -- proper permissions to your database.

Your DBA should be able to help.

1
  • 1
    Then you need to give NETWORK SERVICE rights on the SQL server and you should be good to go. Mar 25, 2011 at 22:22
0

It is difficult to provide you with an exact answer because you have not provided your connection string or info on your SQL Server config. Your best bet is to look at the IIS configuration and work out what user is attempting to access the different SQL Server. You then need to give this account access to the database. This is a common problem and most of the changes need to happen in SQL Server unless you can change the account that the web server is running under.

1
  • Basically my connection string is like this: "Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;" Mar 25, 2011 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.