Link to home
Start Free TrialLog in
Avatar of vkarumbaiah
vkarumbaiahFlag for United States of America

asked on

"Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."

Hi

Im building an ASP.Net page in VB.Net 2005.
In my solution I have included the web project and a db functions component that handles all database requests.

On load the page instantiates the db functions component and executes a function that retrieves data from the database.

I have set up the default security under IIS to run under a user account that I kbow has dbowner permissions on the databse.

When I run the project I get the error "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection."

how can I set up IIS so the page and the subsequent calls to other components run under the context of the use setup on IIS?

Thank you for any help in this regard.
ASKER CERTIFIED SOLUTION
Avatar of existenz2
existenz2
Flag of Netherlands 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
If you want the proper connection string for a trusted connection user go to: www.connectionstrings.com. They list all types of DB connections and the strings to use for each one.
Avatar of maidinhtai
maidinhtai

Go to Directory Sercurity tab (IIS) -> Edit -> Check Integrated Windows authentication
Avatar of vkarumbaiah

ASKER

Hi maidinhtai

Yes Ive already done that however, it did not solve the problem.
The website runs but I get the same error when the component with the db functions tries to access the database.

I did get it to work and I can continue with development however this is not a pretty solution and definitely not production ready.
What did was, I had to set the Local Impersonation to use an account that has permissions to access the databse in the web.config.
i.e ASP.net tab (IIS) -> Edit Configuration -> ASP.Net Configuration settings -> Application -> Identity Settings -> Local Imersonation

This modifies the web.config file of the asp.net application and adds the following elements to the web.config file
<identity impersonate="true" userName="myusername" password="mypassword" />

This works but I want to find a way to achieve this without having to store the user id and password in a text file.

existenz2 - I am yet to try the suggestion in the article you suggested As the article sugests my production IIS server and sql server are on seperate machines.





existenz2

I read the link you posted and Part two of the suggested solution applies to my situation i.e. as below

1. Type inetmgr from your command prompt and give enter.
2. This would open the IIS Control Panel.
3. Expand the appropriate nodes and select the Virtual Directory of your application.
4. Right Click and select Properties.
5. Switch to the Directory Security Tab.
6. Under Anonymous access and authentication control click Edit
7. Check the Enable Anonymous access in case you want people to access the application without logging in with Windows Logon Screen.
8. Uncheck the Allow IIS to control password and enter the DomainName/UserName and Password in the respective boxes. Usually IIS uses IUSER_MACHINENAME credentials for Anonymous access.
9. Uncheck if any other authentication mode is checked and then press Ok twice to exit.
10. Then in web.config you can use either one of these connection strings:

i. "data source=yourservername;initial catalog=databasename;Integrated Security=SSPI"

ii. "server=yourservername; database=databasename;Trusted_Connection=true"


Thank you for your help, that was an excellent resource!