views:

290

answers:

1

Hi,

We are developing an intranet web application on .NET 2.0 platform. The application is using Integrated Windows Authentication for Single Sign On. The users are authorized to use diffent modules according to the Active Directory Groups they are in.

Up to the point where authentication and authorization is accomplished everything works fine. But the problem starts when application tries to connect to the database on MSSQL Server.

According to the security policies of our customer, no database user or password data should be kept in connection strings or in registry even if encrypted. So we are forced to use Integrated Security=SSPI in the connection string.

The Application Pool on IIS is configured by them with the Identity User who has access to the database.

When we deactivate Windows Integrated Authentication, we connect to the db with the Application Pool's Identity User. But when Integrated Authentication is on, the application is trying to connect to the database with logon user credentials.

We tried every combination of Integrated Authentication, with or without impersonation, to solve the problem.

Is there any way to solve this conflict?

+1  A: 

Normally the way you are doing it should work. Do you have Kerberos with delegation enabled?

Maybe this helps:

Edit: if both SQL and IIS are on the same machine you need to turn off impersonate:

  • <authentication mode="Windows" />
  • <identity impersonate="false" />
chris
No, Kerberos doesn't enabled. I will try Kerberos, thanks for quick reply.
mrt
Well actually I was wondering if Kerberos is making the problems. Is your SQL Server then on the same machine as IIS?
chris
No, SQL Server and IIS are on different machines, but on the same domain.
mrt
That's strange since Windows can't delegate identity across the network without Kerberos. Still, try <identity impersonate="false" />
chris
when impersonation is <identity impersonate="false" /> db connection ok but i can not get logon user identity
mrt
when impersonation is <identity impersonate="true" /> i can get logon user identity but when trying to connect to the db i get this error.System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
mrt
Where do you get the user identity from? Use HttpContext.Current.User with impersonate="false". see http://msdn.microsoft.com/en-us/library/aa302377.aspx
chris
This solves our problem. We get current identity from System.Security.Principal.WindowsIdentity.GetCurrent(). We are now using HttpContext.Current.User. Thank you very much.
mrt