Skip to content Skip to sidebar Skip to footer

Database Connections Work Fine When Application Is Run From Localhost. Login Fails From Dev Server

I have an application which connects to a database, retrieves a username from a user's table and matches it against the username retrieved with System.Security.Principal.WindowsIde

Solution 1:

It appears that your application is attempting to connect to the database under the ASPNET account, which may have limited permissions on the development server, as opposed to logging in on your own (you local machine may actually be using your windows identity). I can see two potential solutions.

  1. Make sure to add into the system.web section of your web.config file.

  2. Check with the system administrator and the SQL administrator to make sure the ASPNET account has proper authorization to connect to the database, if indeed your environment allows this account to connect.

Adding some additional code to your question, such as your connection string may help things out as well.

EDIT: Okay, you are indeed using IntegratedSecurity, so typically with this kind of setup (using impersonation), you need to make sure you are getting prompted to add your Username and Password to authenticate against.

We have a similar setup, and to do this, we have to go to the IIS settings for the virtual directory, select the Directory Security tab, and click the Edit button under Anonymous access and authentication control.

Make sure Anonymous access is unchecked, and you may will most likely need to enable the proper authentication for your environment. Unfortunately we're still using Basic authentication (clear text) here, but Integrated Windows authentication may will work for you too. It depends on your environment.

I'm adding this comment to the main post since this seemed to have done the trick...

I just found this post which may help you get the proper configuration setup to handle what you need based on your IIS environment.

Solution 2:

The answer may lay with your connection string. My guess would be that you are using integrated authentication to log into the database. This works fine when it's your machine because the application is using your credentials. When you publish to the development server you would be using the aspNet user and wouldn't have the right credentials to login. I would either add this user to your database server or change your connection string to use SQL authentication.

Solution 3:

It could be a firewall setting that's preventing your server from seeing your database.

It might also have something to do with your connection string. If you're using anything besides a username/password combo in your web.config file, you will probably require additional configuration to convince the database server to let you connect.

Solution 4:

It seems that what you want to do is impersonate the caller of the web page. You need to add a line to your web.config to do this:

<identityimpersonate="true" />

See this article for an explanation.

Post a Comment for "Database Connections Work Fine When Application Is Run From Localhost. Login Fails From Dev Server"