Solved

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

Posted on 2006-06-09
5
356 Views
Last Modified: 2010-08-05
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.
0
Comment
Question by:vkarumbaiah
5 Comments
 
LVL 14

Accepted Solution

by:
existenz2 earned 125 total points
ID: 16870350
It's not a IIS problem, but a connection string/SQL Server problem. Have a look at:

http://geekswithblogs.net/ranganh/archive/2005/05/25/40489.aspx

0
 
LVL 28

Expert Comment

by:strickdd
ID: 16870629
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.
0
 
LVL 3

Expert Comment

by:maidinhtai
ID: 16873411
Go to Directory Sercurity tab (IIS) -> Edit -> Check Integrated Windows authentication
0
 
LVL 1

Author Comment

by:vkarumbaiah
ID: 16879443
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.





0
 
LVL 1

Author Comment

by:vkarumbaiah
ID: 16880905
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!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now