Here is my question: Is there a way to have ASP.Net pass through the previously authenticated Windows user credentials to SQL server without providing hard-coded user information either in the web.config or in the ASP.Net code itself?
Here is my scenario:
Building a suite of Intranet tools for my company. The web server is a Windows 2003 Server in an Active Directory domain, where the SQL Server 2000 system is on a seperate machine. Both the web server and the SQL server are within the same Active Directory domain.
Each Intranet tool is seperate web page, which is part of a single ASP.Net solution. We need to provide explicit permissions for each tool and we have SQL groups assigned to provide specific permissions at the SQL level as well. So that User A using Tool B only has SELECT permissions for Table C, but User B using Tool D has SELECT, INSERT and UPDATE permissions for TableC.
We have IIS on the web server setup for Windows Integrated Authentication, with no anonymous users allowed. My thought was that ASP.Net would use the authenticated user credentials (from when the user had to provide them at the first page hit) and pass them through to the SQL server when any calls were made -- it would appear that this is not the case however.
The SQL server is setup as Mixed Mode, and my SQL connection string is setup as follows:
Data Source=[MY SQL SERVER];Initial Catalog=[MY SQL DATABASE];Trusted_Connecti
on=yes
In the web.config, I have the <authentication mode="Windows"> tag set, as well as <authorization> set to <allows users="*" />.
When the application page is first hit with a new browser, I am presented with a Windows logon dialog. Upon succsfully entering my credentials, the form page is displayed.
I have included display of the following variables in the Page_Load() method to better understand what is happening:
- HttpContext.Current.User.I
dentity.Na
me
- WindowsIdentity.GetCurrent
().Name
- Thread.CurrentPrincipal.Id
entity.Nam
e
Upon entering a value into my textbox and hitting the submit button - the SQL call is made. This is when I receive the SQL errors.
When I have <identity impersonate="false"> in the web.config, I get the following results:
- [SQL ERROR]: Login failed for user 'MY_DOMAIN\MY_MACHINE_NAME
$'.
- HttpContext.Current.User.I
dentity.Na
me = [MY DOMAIN\MY LOGON USER]
- WindowsIdentity.GetCurrent
().Name = [NT AUTHORITY\NETWORK SERVICE]
- Thread.CurrentPrincipal.Id
entity.Nam
e = [MY DOMAIN\MY LOGON USER]
When I have <identity impersonate="true"> set in the web.config, I get these results instead:
- [SQL ERROR]: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
- HttpContext.Current.User.I
dentity.Na
me = [MY DOMAIN\MY LOGON USER]
- WindowsIdentity.GetCurrent
().Name = [MY DOMAIN\MY LOGON USER]
- Thread.CurrentPrincipal.Id
entity.Nam
e = [MY DOMAIN\MY LOGON USER]
All I want is to be able to have the system "Pass Through" the already authenticated logged in domain user credentials to the SQL server as the permissions to be used for validating the SQL code. Can anyone point me to the correct information on how this can be done in a multiple server environment?
So far every solution I have encountered talks about providing a single account to be used for SQL operations (whether it be the IIS_WPG or a custom designed domain account), and either describes setting up delegation for seperate server setups -- or hard coding user credentials in config or code files. All I want to do is to use the already supplied user credentials for ALL security permission checks. Can this be done? Or will we have to rethink how the security for our Intranet is to be setup?
Thanks in advance for your replies and taking the time to read this.