473,748 Members | 2,467 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 #1
15 3312
> 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.


I spent a lot of time fighting this error message and eventually figured it
all out.

How are you specifying the username and password that you want the process
to impersonate?

The way I solved this was as follows (this assumes you're not running in IIS
5.0 isolation mode):

1. Create a domain user that is allowed to access the SQL Server database.

2. On your Windows Server 2003 PC, edit the IIS_WPG usergroup and add the
user you have configured.

3. Right-click the DefaultAppPool in IIS Manager and select Properties. On
the Identity tab, select "Configurab le" and then enter the DOMAIN\UserName
and Password values into the appropriate boxes.

4. Back in IIS Manager, select Properties for your web site and ensure that
its Application pool is set to DefaultAppPool, that it has an Application
name (click Create if it's not set) and that the Execute permissions are set
to Scripts only.

With this all done, it worked fine for me, using the user credentials
entered against the Application pool as its impersonation user.

Hope that helps,

--

(O)enone
Nov 19 '05 #2
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.

"Oenone" wrote:
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.


I spent a lot of time fighting this error message and eventually figured it
all out.

How are you specifying the username and password that you want the process
to impersonate?

The way I solved this was as follows (this assumes you're not running in IIS
5.0 isolation mode):

1. Create a domain user that is allowed to access the SQL Server database.

2. On your Windows Server 2003 PC, edit the IIS_WPG usergroup and add the
user you have configured.

3. Right-click the DefaultAppPool in IIS Manager and select Properties. On
the Identity tab, select "Configurab le" and then enter the DOMAIN\UserName
and Password values into the appropriate boxes.

4. Back in IIS Manager, select Properties for your web site and ensure that
its Application pool is set to DefaultAppPool, that it has an Application
name (click Create if it's not set) and that the Execute permissions are set
to Scripts only.

With this all done, it worked fine for me, using the user credentials
entered against the Application pool as its impersonation user.

Hope that helps,

--

(O)enone

Nov 19 '05 #3
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 #4
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 #5
this will only work if the sqlserver is on the same box as IIS. this is
because ntlm authentication does not allow forwarding of creditals (1 hop
rule). you have 4 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.
-- bruce (sqlwork.com)

"Patrick" <qu*******@news group.nospam> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
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 #6
Why does it work when the ASP.NET is on IIS5.1 on WinXP SP1 (which is on a
different box but in the same domain as the SQL Server)?

"Bruce Barker" wrote:
this will only work if the sqlserver is on the same box as IIS. this is
because ntlm authentication does not allow forwarding of creditals (1 hop
rule). you have 4 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.
-- bruce (sqlwork.com)

"Patrick" <qu*******@news group.nospam> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
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 #7
WJ

"Patrick" <qu*******@news group.nospam> wrote in message
news:E6******** *************** ***********@mic rosoft.com...
Why does it work when the ASP.NET is on IIS5.1 on WinXP SP1 (which is on a
different box but in the same domain as the SQL Server)?


Because you "login" to Windows XP where the IIS-5 is on the same box. This
is called integrated Windows security.

John
Nov 19 '05 #8
Thanks a lot for Bruce and John's informative inputs.

Hi Patrick,

For the ASP.NET impersonation, when we use implicit impersonation like:

<identity impersonate="tr ue" />

the remote client's credential will be used to establish a network logon
session which doesn't have network credential for further network hop.
That's why for general condition, when client visist your asp.net app and
the asp.net use clientside credential to access the remote sqlserver will
fail.

For the local IIS5 XP condition, because you are test through the local
browser , when the IIS accept the clientside credential (local client), it
directly use the client user's interactive logon session( rather than
establish a network logon session) which surely contains the network
credential, so in such condiitino, the asp.net is able to use the
credential to access the remote sqlserver.

Anyway, I think Bruce has completely listed all the possible solutions
currently we have. If there're anything else unclear ,please feel free to
post here.

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.)


--------------------
| From: "WJ" <Jo*******@HotM ail.Com>
| References: <5A************ *************** *******@microso ft.com>
<#k************ **@tk2msftngp13 .phx.gbl>
<E6************ *************** *******@microso ft.com>
| Subject: Re: ASP.NET -> SQL Server : Impersonation not working!
| Date: Mon, 8 Aug 2005 20:58:36 -0400
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| Message-ID: <OE************ **@TK2MSFTNGP10 .phx.gbl>
| Newsgroups:
microsoft.publi c.dotnet.framew ork.adonet,micr osoft.public.do tnet.framework. a
spnet
| NNTP-Posting-Host: ip70-187-233-38.dc.dc.cox.ne t 70.187.233.38
| Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| Xref: TK2MSFTNGXA01.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:1168 26
microsoft.publi c.dotnet.framew ork.adonet:3367 9
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
|
| "Patrick" <qu*******@news group.nospam> wrote in message
| news:E6******** *************** ***********@mic rosoft.com...
| > Why does it work when the ASP.NET is on IIS5.1 on WinXP SP1 (which is
on a
| > different box but in the same domain as the SQL Server)?
| >
|
| Because you "login" to Windows XP where the IIS-5 is on the same box.
This
| is called integrated Windows security.
|
| John
|
|
|

Nov 19 '05 #9
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!

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)?
"WJ" wrote:

"Patrick" <qu*******@news group.nospam> wrote in message
news:E6******** *************** ***********@mic rosoft.com...
Why does it work when the ASP.NET is on IIS5.1 on WinXP SP1 (which is on a
different box but in the same domain as the SQL Server)?


Because you "login" to Windows XP where the IIS-5 is on the same box. This
is called integrated Windows security.

John

Nov 19 '05 #10

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

Similar topics

11
1552
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
5062
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
2070
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
1161
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
1009
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
3224
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
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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
9552
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
9376
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...
1
9326
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9249
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
4607
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...
1
3315
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
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.