473,765 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET -> SQL Server : Impersonation not working!

I set my web.config as follows:
<authenticati on mode="Windows" />
<identity impersonate="tr ue" />

Logon to my ASP.NET website as a user who can authenticate to the target
database.

1) Works fine on my local PC running IIS5.1 on WinXP Pro SP1
2) does not work on IIS6.0 on Windows 2003 server:
System.Data.Sql Client.SqlExcep tion: Login failed for user '(null)'. Reason:
Not associated with a trusted SQL Server connection.
at System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )
at
System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne ctionString options, Boolean& isInTransaction )
at System.Data.Sql Client.SqlConne ction.Open()
at Microsoft.Pract ices.Enterprise Library.Data.Da tabase.OpenConn ection()
HOWEVER, Environment.Use rName returns the correct username!
Why? How to fix?
Nov 19 '05
15 3314
On Tue, 9 Aug 2005 02:31:59 -0700, "Patrick" <qu*******@news group.nospam> wrote:

¤ But surely, when I login to my XP, then open up
¤ http://myServer/impersonation.aspx, my IE6 browser also pass in my
¤ credentials to myServer, and that is called Integrated Windows
¤ Authentication, too regardless of whether myServer is IIS6.0 or IIS5.1, as
¤ long as it is in the same domain!
¤

No, NTLM does not pass credentials to IIS when your web app is configured for Integrated Windows
security. NTLM handles the authentication. In order to delegate credentials via the web server NTLM
must be used in conjunction with Kerberos.

¤ How else did myServer managed to log Environment.Use rName correctly
¤ (corresponding to the user launching http://myServer/impersonation from a
¤ remote WinXP IE6 browser in the same domain)?
¤

As was mentioned, the difference is that IIS is not capable of forwarding encrypted credentials (it
does not have) for delegation to a remote server when using Integrated Windows security. This is
different than being authenticated locally on your machine where the credentials are known and can
be forwarded for remote resource authentication. In addition, while the authenticated user name may
be known, the password is not.

BTW if you were using Basic authentication, where clear text credentials can be delegated remotely,
the integrated security mechanism should function as you expect.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #11
I have the same problem. Is there a book or something that spells out exactly
what needs to happen to make this work? I also have it working locally with
XP (so i thought this solution was good), promoted it to the server, only to
run into this problem. Seems to be more difficult than it has to be for
something that appears to be common to do (retrieve data from your SQL server
and display it in your .net pages).

Looking for an answer also,
lyners

"Patrick" wrote:
I set my web.config as follows:
<authenticati on mode="Windows" />
<identity impersonate="tr ue" />

Logon to my ASP.NET website as a user who can authenticate to the target
database.

1) Works fine on my local PC running IIS5.1 on WinXP Pro SP1
2) does not work on IIS6.0 on Windows 2003 server:
System.Data.Sql Client.SqlExcep tion: Login failed for user '(null)'. Reason:
Not associated with a trusted SQL Server connection.
at System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )
at
System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne ctionString options, Boolean& isInTransaction )
at System.Data.Sql Client.SqlConne ction.Open()
at Microsoft.Pract ices.Enterprise Library.Data.Da tabase.OpenConn ection()
HOWEVER, Environment.Use rName returns the correct username!
Why? How to fix?

Nov 19 '05 #12
Hi Lyners,

For such accessing remote resource on client's forward identity issue, you
can refer to
Bruce's former message whicn mentioned the 4 possible options:
===============

1) switch to basic authentication. this will give IIS a primary token it
can
use to access a remore sqlserver.
2) switch to kerberos authentication and enable creditials forwarding.
3) use a fixed account
4) move the SqlServer to the IIS box.

=============== =

In addition, if you have interests, I also recommend that you have a look
at the

"Programmin g windows security" or
"The .NET Developer's Guide to Windows Security"

authored by Keith Brown. The twos are good guide on windows security
programming.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: ASP.NET -> SQL Server : Impersonation not working!
| thread-index: AcWd9XWiDDZC3Jc zQtemxmLiosdewg ==
| X-WBNR-Posting-Host: 204.194.251.3
| From: =?Utf-8?B?THluZXJz?= <Ly****@discuss ions.microsoft. com>
| References: <5A************ *************** *******@microso ft.com>
| Subject: RE: ASP.NET -> SQL Server : Impersonation not working!
| Date: Wed, 10 Aug 2005 14:50:01 -0700
| Lines: 33
| Message-ID: <95************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups:
microsoft.publi c.dotnet.framew ork.adonet,micr osoft.public.do tnet.framework. a
spnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GXA03.phx.gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1172 66
microsoft.publi c.dotnet.framew ork.adonet:3379 7
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| I have the same problem. Is there a book or something that spells out
exactly
| what needs to happen to make this work? I also have it working locally
with
| XP (so i thought this solution was good), promoted it to the server, only
to
| run into this problem. Seems to be more difficult than it has to be for
| something that appears to be common to do (retrieve data from your SQL
server
| and display it in your .net pages).
|
| Looking for an answer also,
| lyners
|
| "Patrick" wrote:
|
| > I set my web.config as follows:
| > <authenticati on mode="Windows" />
| > <identity impersonate="tr ue" />
| >
| > Logon to my ASP.NET website as a user who can authenticate to the
target
| > database.
| >
| > 1) Works fine on my local PC running IIS5.1 on WinXP Pro SP1
| > 2) does not work on IIS6.0 on Windows 2003 server:
| > System.Data.Sql Client.SqlExcep tion: Login failed for user '(null)'.
Reason:
| > Not associated with a trusted SQL Server connection.
| > at System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
| > isInTransaction )
| > at
| >
System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne c
tionString options, Boolean& isInTransaction )
| > at System.Data.Sql Client.SqlConne ction.Open()
| > at
Microsoft.Pract ices.Enterprise Library.Data.Da tabase.OpenConn ection()
| > HOWEVER, Environment.Use rName returns the correct username!
| >
| >
| > Why? How to fix?
|

Nov 19 '05 #13
Assuming you are using windows auth to connect to SQL Server - which it
looks like you are - you are more than likely running into the infamous
"double hop" issue. You cannot go from client -> (one hop) web server ->
(2nd hop) sql server unless you allowed delegation for the account that are
trying to authenticate.

It is possible to achieve what you are trying to do, but it will require
some additional setup. Check out these links for more info:

http://odetocode.com/Blogs/scott/arc...2/24/1053.aspx
http://support.microsoft.com/default...b;en-us;810572
http://pluralsight.com/blogs/keith/a...7/08/1586.aspx

Kevin Cunningham

"Lyners" <Ly****@discuss ions.microsoft. com> wrote in message
news:95******** *************** ***********@mic rosoft.com...
I have the same problem. Is there a book or something that spells out
exactly
what needs to happen to make this work? I also have it working locally
with
XP (so i thought this solution was good), promoted it to the server, only
to
run into this problem. Seems to be more difficult than it has to be for
something that appears to be common to do (retrieve data from your SQL
server
and display it in your .net pages).

Looking for an answer also,
lyners

"Patrick" wrote:
I set my web.config as follows:
<authenticati on mode="Windows" />
<identity impersonate="tr ue" />

Logon to my ASP.NET website as a user who can authenticate to the target
database.

1) Works fine on my local PC running IIS5.1 on WinXP Pro SP1
2) does not work on IIS6.0 on Windows 2003 server:
System.Data.Sql Client.SqlExcep tion: Login failed for user '(null)'.
Reason:
Not associated with a trusted SQL Server connection.
at System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )
at
System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne ctionString
options, Boolean& isInTransaction )
at System.Data.Sql Client.SqlConne ction.Open()
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabase.OpenConn ection()
HOWEVER, Environment.Use rName returns the correct username!
Why? How to fix?

Nov 19 '05 #14
Actually, if the user is logged onto our intranet, that is good enough
security. I am trying to make the IIS talk to the SQL server, I have been
experimenting with different setups, but i can't get any data back. I usually
get "Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server connection" What is the correct way to setup a connection to a SQL
server running on a Windows 2003 server from an IIS Windows 2003 server? I
know the second hop is my problem, but what is the best business practice for
setting up the conection?

"kevin cunningham" wrote:
Assuming you are using windows auth to connect to SQL Server - which it
looks like you are - you are more than likely running into the infamous
"double hop" issue. You cannot go from client -> (one hop) web server ->
(2nd hop) sql server unless you allowed delegation for the account that are
trying to authenticate.

It is possible to achieve what you are trying to do, but it will require
some additional setup. Check out these links for more info:

http://odetocode.com/Blogs/scott/arc...2/24/1053.aspx
http://support.microsoft.com/default...b;en-us;810572
http://pluralsight.com/blogs/keith/a...7/08/1586.aspx

Kevin Cunningham

"Lyners" <Ly****@discuss ions.microsoft. com> wrote in message
news:95******** *************** ***********@mic rosoft.com...
I have the same problem. Is there a book or something that spells out
exactly
what needs to happen to make this work? I also have it working locally
with
XP (so i thought this solution was good), promoted it to the server, only
to
run into this problem. Seems to be more difficult than it has to be for
something that appears to be common to do (retrieve data from your SQL
server
and display it in your .net pages).

Looking for an answer also,
lyners

"Patrick" wrote:
I set my web.config as follows:
<authenticati on mode="Windows" />
<identity impersonate="tr ue" />

Logon to my ASP.NET website as a user who can authenticate to the target
database.

1) Works fine on my local PC running IIS5.1 on WinXP Pro SP1
2) does not work on IIS6.0 on Windows 2003 server:
System.Data.Sql Client.SqlExcep tion: Login failed for user '(null)'.
Reason:
Not associated with a trusted SQL Server connection.
at System.Data.Sql Client.Connecti onPool.GetConne ction(Boolean&
isInTransaction )
at
System.Data.Sql Client.SqlConne ctionPoolManage r.GetPooledConn ection(SqlConne ctionString
options, Boolean& isInTransaction )
at System.Data.Sql Client.SqlConne ction.Open()
at
Microsoft.Pract ices.Enterprise Library.Data.Da tabase.OpenConn ection()
HOWEVER, Environment.Use rName returns the correct username!
Why? How to fix?


Nov 19 '05 #15
Hi Patrick,

Have you had a chance to look at Paul and Kevins' further suggestions.
Also, as I mentioned in my former reply, currently the four options Bruce
has suggested:
=========
1) switch to basic authentication. this will give IIS a primary token it
can
use to access a remore sqlserver.
2) switch to kerberos authentication and enable creditials forwarding.
3) use a fixed account
4) move the SqlServer to the IIS box
=========

are the reasonable approach avaiable for multi-tier application. Please
feel free to post here if there'r anything else we can help. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: ASP.NET -> SQL Server : Impersonation not working!
| thread-index: AcWcOezYxxuAGdP fQ5acH2lDwOZtOg ==
| X-WBNR-Posting-Host: 198.240.128.75
| From: "=?Utf-8?B?UGF0cmljaw= =?=" <qu*******@news group.nospam>
| References: <5A************ *************** *******@microso ft.com>
<ex************ **@TK2MSFTNGP10 .phx.gbl>
<F1************ *************** *******@microso ft.com>
<##************ **@TK2MSFTNGP15 .phx.gbl>
| Subject: Re: ASP.NET -> SQL Server : Impersonation not working!
| Date: Mon, 8 Aug 2005 09:55:05 -0700
| Lines: 27
| Message-ID: <94************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups:
microsoft.publi c.dotnet.framew ork.adonet,micr osoft.public.do tnet.framework. a
spnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GXA03.phx.gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1167 40
microsoft.publi c.dotnet.framew ork.adonet:3365 3
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| wanting the user credentials to be those of the user in whose identity
the
| browser is running? (For example, if I logged on to your network as
| MYDOMAIN\Fred and opened the web browser, would you want the connection
to
| the server to be under the user credentials of MYDOMAIN\Fred?)
|
| "Oenone" wrote:
|
| > Patrick wrote:
| > > What I do NOT want connection to the SQL Server to be with a fixed
| > > Domain username/password, but rather I want the user to pass the
| > > username/password from the web browser to IIS6 and for IIS6/ASP.NET
| > > to pass the credentials to SQL Server.
| >
| > Aha -- I'm not sure how you'd do it in that case...
| >
| > Are you wanting the user credentials to be those of the user in whose
| > identity the browser is running? (For example, if I logged on to your
| > network as MYDOMAIN\Fred and opened the web browser, would you want the
| > connection to the server to be under the user credentials of
MYDOMAIN\Fred?)
| > Or would you want the user to type them into a form in the browser?
| >
| > --
| >
| > (O)enone
| >
| >
| >
|

Nov 19 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1555
by: Steven Burn | last post by:
I'm curious as I am in need of advice on how I can move a site from an old Win 2K server, to it's new home on a Win 2003 server, without having to mess around with downloading/uploading the file's (there's over 30,000 file's/folders, so it would take forever to do it manually). Thus, anyone have any idea on how one would proceed with doing this? (I've heard of an ASP script thats capable of this, but can't seem to locate it). TIA
12
5064
by: Gaurav | last post by:
Hello I have a program that basically inverts the contents of files except first line. It compiles fine but gives me core dump on running. If i comment temp.clear() it runs fine, but i need it to clear the temp vector for each file. ********************* code *******************
9
2072
by: Ludwig Moser | last post by:
hello newsgroup! my problem is that after successful compiling the exe is running, but ONLY on my system i am using visual studio .net 2003 J# so: 1) why? 2) what can i do to change this?
4
4274
by: Tim Mulholland | last post by:
I have one page where i have some <div> tags set to be runat="server" (and i've given them an id) and i can access them from the code-behind file just fine. I have another page where i've done essentially the same thing (even copying the code from the other file) and i cannot access them from the code-behind file. Any clues what would cause this? Just a tad frustrating because i can't move forward on this page without
1
1163
by: Frank | last post by:
I have an IIS 5.0 server that is running both .NET 1.0 and .NET 1.1 applications. I installed .NET 1.0 first. Recently I added .NET 1.1 just for specific new IIS virtual directories. A problem I've encountered is that for some reason my customErrors
2
3288
by: Annu | last post by:
Hi I need help on <enbed> tag. Following code(No 1) is working properly on windows but on linux code no.2 is not working Code No 1: <EMBED type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
0
991
by: tomaszh | last post by:
Hello, We are having a problem transfering large amounts of data ( > 3MB) over remoting. The problem only seems to occur when data is transfered from the client to server, as we have successfully transfered ~23MB of data from server to the client using the same method. We are using a DataTable with several columns where one of them is holding a byte array to transfer files. Remoting settings: using WellKnownObjects available via IIS,...
0
1010
by: Bill | last post by:
I have a .NET 2.0 application running on Windows 2003 Enterprise. Root directory adds a custom http module. <httpModules> <add name="SitesModule" type="Classes.SitesModule"/> </httpModules> That works...
0
3226
by: anand4160 | last post by:
i use nowrap="nowrap" attribuate to fix my UI for IE 6 , now when i am trying to run the same code in IE 8 its not working. The code is simple to display table. nowrap="nowrap" is written in the main CSS file , and its get applied to all site. its working fine with IE6 and 7 , but problem is in IE 8. In IE8 text in table <td /> displaying in one line and and crossing the window layout. Can any of you suggest me how to fix it?
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9833
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.