Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this SQL Server instance which has different write/read permission for different Domain Users (Groups) in my LAN.
Currently, I am developing an Intranet ASP.NET Application which uses Windows Authentication.
But, When I tried to connect the SQL through Application, It shows this error
Login failed for user 'DOMAIN\SERVER_NAME$'. 

Can I use the same logged in Domain permission to connect the SQL Server,
or Can I log in to the SQL Server without switching on 'SQL Server Authentication' on my SQL Server ?
Posted
Comments
[no name] 9-Mar-15 10:05am    
Which authentication are u used? and ur connection string?
Yesudass Moses 10-Mar-15 1:20am    
Windows Authentication..
and, the connection string is ::
"data source=SQL-SERVER;Integrated Security=SSPI;Initial Catalog=DB_NAME;"

1 solution

You need to enable impersonation:
Using IIS Authentication with ASP.NET Impersonation[^]
XML
<configuration>
  <system.web>
    <identity impersonate="true" />
  </system.web>
</configuration>


If SQL is not on the same server as IIS, you will need to perform additional configuration - in particular, make sure the IIS server is trusted for delegation, and that you're using Kerberos instead of NTLM.

Checklist for Double Hop issues {IIS and SQL Server}[^]
How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0[^]


Ensure your Application server is set as Trusted for Delegation. Ensure in IIS that Anonymous Authentication is disabled and Windows Authentication is enabled, if using Windows 2008, enable ASP.Net Impersonation also. If using Windows 2008 and your app pool is running under Network Service then goto Advanced settings of Windows Authentication and turn Kernal Mode off. Set yourDomain\yourAppServer$ to have read access to the ASP.Net application folder.


If you still can't get it to work, you might need to switch from Windows to Basic authentication:

In IIS, only Basic Authentication logs users on with a security token that flows across the network to a remote SQL server. By default, other IIS security modes used in conjunction with the identity configuration element settings will not result in a token that can authenticate to a remote SQL Server.
 
Share this answer
 
v2
Comments
Yesudass Moses 10-Mar-15 1:17am    
When I use Impersonate, It shows this error:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
Richard Deeming 10-Mar-15 7:56am    
Sounds like you're hitting the "double-hop" problem. I've added some links to my answer which might help.

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