impersonate with SQL Server on the same domain

M

Mark

We are attempting to use impersonation to connect from our ASP.NET website
to a SQL Server on the same domain. The code below works just fine in our
web.config file:

<identity impersonate="true" userName="mydomain\mylogin"
password="whatever">

However, if we attempt to impersonate the user that currently is logged in
to the client computer using ...

<identity impersonate="true">

we get the error message:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

I'm an SA on the SQL Server box ... something else isn't quite clicking.
Any recommendations? In IIS we have Integrated Windows Authentication
checked, and nothing else.

Thanks in advance.

Mark
(e-mail address removed)
 
B

bruce barker

to pass the users credentials to the sqlserver (on a different box),
delegation is required. ntlm does support delegation. only basic (which
gives iis a primary token which is allowed 1 hop) and digest (if delegation
is enabled) support passing user creditals from the iis box to a different
box.

-- bruce (sqlwork.com)
 
M

Mark

Bruce,

I executed the following code:

System.Security.Principal.IIdentity ii = User.Identity;
System.Security.Principal.WindowsIdentity wi = WindowsIdentity.GetCurrent();

Response.Write("<br>IIdentity.AuthenticationType: " +
ii.AuthenticationType);
// Displays: IIdentity.AuthenticationType: Negotiate

Response.Write("<br>WindowsIdentity.AuthenticationType: " +
wi.AuthenticationType);
// Displays: WindowsIdentity.AuthenticationType: NTLM

??? What does this say?

Also, how does one enable delegation as opposed to impersonation?

Thanks for your help. We appreciate it.

Mark
(e-mail address removed)
 
M

Mark

Curt,

I'm not sure if this is good news, BUT it did work when I checked Basic. In
fact, it worked when I had Basic checked both with and without integrated
checked.

What does this mean? The thought of needing basic does not sound good on
the surface, but I'm no IIS guru.

Thanks!

Mark
 
C

Curt_C [MVP]

write out the user that the system thinks you are when you use Integrated.
It may be as simple as "user" vs "domain\user"

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
 
M

Mark

Curt,

I tried:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
which should display the impersonated user. With or without the Basic
checked, it displayed the domain/user.

What does this imply? Thanks again.

Mark
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,132
Latest member
TeresaWcq1
Top