I'm currently working on an ASP.Net / C# / Entity Framework project using Windows Authentication.
I would like my users to reach both IIS Server and SQL Server with their own Active Directory account, allowing administrators to see who is connected to the database.
But I have an issue: while connecting to the database, the program uses the application pool's account set up in the IIS Server, but not his user account.
This is my web.config
file :
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<customErrors mode="Off"/>
<authentication mode="Windows"/>
<identity impersonate="true"/>
</system.web>
<connectionStrings>
<add name="BOMBuilderEntities"
connectionString="metadata=
res://*/Model.BOMBuilderModel.csdl|
res://*/Model.BOMBuilderModel.ssdl|
res://*/Model.BOMBuilderModel.msl;
provider=System.Data.SqlClient;
provider connection string=
'data source=FRSDSQ01;
initial catalog=BOMBuilder;
integrated security=SSPI;
MultipleActiveResultSets=True;
App=EntityFramework'"
providerName="System.Data.EntityClient"/>
</connectionStrings>
<system.webServer>
<defaultDocument>
<files>
<add value="multipages.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Also, I tried to modify this ApplicationPoolIdentity
setting to see if it was this connection used for SQL Server authentication and it is. If I set a domain account, this account will be listed in the activity monitor. So how can I set this setting in order to use the user account logged on my asp.net application?
EDIT 1: I've added the impersonation setting.
This may be a case of Double-Hopping. This is when the IIS server and the SQL Server are on different machines, it is a security measure that refuses to continue to provide the credentials to servers further down the chain unless proper delegation is in place.
A quote from the second article:
Further information can be found in the following articles: http://blogs.technet.com/b/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx http://blogs.msdn.com/b/knowledgecast/archive/2007/01/31/the-double-hop-problem.aspx