Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have web application where I connect application with SQL. I host this website on local machine. it works properly, but when need to fetch data from SQL server it getting error that `Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

My web.config code as below
HTML
<connectionStrings>
		<add name="ConnString" connectionString="Data Source=INMUM;Initial Catalog = DB_ERS;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
		<add name="DB_FRSConnectionString" connectionString="Data Source=INMUM;Initial Catalog=DB_ERS;Integrated Security=False"  providerName="System.Data.SqlClient" />
	</connectionStrings>
	
Is there anything wrong? or I need to any other this as well? 
Please suggest me answer.

What I have tried:

My web.config code as below
<pre lang="HTML"><connectionStrings>
		<add name="ConnString" connectionString="Data Source=INMUM;Initial Catalog = DB_ERS;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
		<add name="DB_FRSConnectionString" connectionString="Data Source=INMUM;Initial Catalog=DB_ERS;Integrated Security=True"  providerName="System.Data.SqlClient" />
	</connectionStrings>
	<system.web>
    <identity impersonate="true" />
		<compilation debug="true" targetFramework="4.5.1">
</system.web>
Posted
Updated 23-Feb-16 3:31am

You either need to provide a SQL username and password in your connection string like this:
XML
<connectionstrings>
   <add name="MyConString" connectionstring="Data Source=serverName;Initial Catalog=dbName;Persist Security Info=True;User ID=someUserId;Password=usersPassword" providername="System.Data.SqlClient" />
 </connectionstrings>


or, keep the connection string you have but change the account being used on your application pool in IIS to an account that has sufficient privileges in SQL.
 
Share this answer
 
Comments
Member 12346179 23-Feb-16 9:33am    
@ryanDev- I would like to go with another solution, How can I check that account has sufficient privileges in SQL.
ZurdoDev 23-Feb-16 9:34am    
Sufficient privileges depend on your app. But it likely needs to be db_reader and db_writer.
The easiest way of fixing this would be to not use Trusted Connection, instead create a SQL account in the SQL Server Management Studio that has access to your database, then supply the username and password of that account in your connection string.

The better way would be to change the account your anonymous user runs under in IIS and give that account access to your database via SQL Management. Google for those things if you don't know how to do them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900