Impersonating other domain user in ASP.Net

C

cmw

I am trying to debug an ASP.Net application that uses impersonation to
access a secured SQL Server database (Microsoft cRM as it happens) so
my web.config has

<authentication mode="Windows" />
<identity impersonate="true"/>
<authorization>
<deny users="?" />
</authorization>

Now I'm not too clued up on authentication, active directory etc so
I'm confused as to how my asp.net app appears to SQL Server as a
totally different domain and user.

Here's the code I've used to demonstrate what's happening.

SqlConnection conn = new
SqlConnection("Trusted_Connection=No;Server=sndbx2003dev;Database=03dev_MSCRM;Integrated
Security=SSPI;");
SqlCommand comm = new SqlCommand("SELECT SUSER_SNAME()", conn);
conn.Open();

Literal1.Text = comm.ExecuteScalar().ToString();
conn.Close();

Literal2.Text = HttpContext.Current.User.Identity.Name;

Now Literal1 has 03dev\crmadmin whereas Literal2 has my own company
\myname login.

I've trying to reproduce the same behaviour on a client's machine and
don't know what's going on. I've asked the network guys but they don't
seem to know either but somethings were set up before them.

I've found references to Kerberos but it's a bit over my head at the
moment.

How is this possible?
 
S

Shaun C McDonnell

cmw,

Have you established domain trusts between the calling and receiving
domains?

Shaun McDonnell
 
C

cmw

cmw,

Have you established domain trusts between the calling and receiving
domains?

I'll look into domain trusts but this is what I don't know about. How
do I find out?

Consultant: Any uid and pwd I add to the connection string makes no
difference as its not an SQL login.
 
C

Consultant

create the sql login account, give it appropriate permissions, dbo reader,
whatever. then in your web.config on your webservices, in the appsettings
section, construct this:

<add key="DBConnStr" value="initial
catalog=insert_your_catalog_name;uid=insert_sql_login;pwd=insert_password;data
source=insert_sql_servername;persist security info=False;"/>

c
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top