473,554 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows authentication from ASP.NET to SQL Server

Hello,

I am having trouble using Integrated Windows Authentication between our
intranet server and our database server, both of which are on our local
domain.

Windows authentication works for our intranet server - my domain user
"DOM\nme" is correctly authenticated and authorized to view the ASP.NET page
on our intranet. The ASP.NET application uses impersonation (<identity
impersonate="tr ue"> in Web.config).

Windows authentication also works for the SQL Server; when logged on to the
domain, I can start Query Analyzer and connect to the SQL Server using
Windows authentication. Permissions on the SQL Server are also correctly set
up.

However, problems arise when I want to connect to the SQL Server from the
ASP.NET page - I get the fairly common error message below:

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

Although I do get a lot of hits when searching for this specific error, I
still can't seem to find the cause of the problem.

The connection string I'm using to connect to the SQL Server is:
"Server=DB;Inte grated Security=SSPI;D atabase=Intrane tDB".

When setting <identity impersonate="fa lse">, I get the error message "Login
failed for user 'DOM\INTRANET$' ." - DOM\INTRANET$ is the hostname of the
intranet server.

In the database servers event log, I can see two events (supplied below)
after trying to authenticate (unsuccessfully ) from the ASP.NET application
to the SQL Server as "DOM\nme".

What do I need to do to let users use Windows authentication against the DB
server as well?
Regards,
Nils Magnus Englund
(event log entries follows...)
Date: 08.08.2005
Source: Security
Time: 15:14:55
Category: Logon/Logoff
Type: Success Audit
Event ID: 540
User: NT AUTHORITY\ANONY MOUS LOGON
Computer: DB

Description:
Successful Network Logon:
User Name:
Domain:
Logon ID: (0x0,0x5CE408)
Logon Type: 3
Logon Process: NtLmSsp
Authentication Package: NTLM
Workstation Name: INTRANET
Logon GUID: -
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: -
Source Port: -
Date: 08.08.2005
Source: Security
Time: 15:14:55
Category: Logon/Logoff
Type: Success Audit
Event ID: 538
User: NT AUTHORITY\ANONY MOUS LOGON
Computer: DB

Description:
User Logoff:
User Name: ANONYMOUS LOGON
Domain: NT AUTHORITY
Logon ID: (0x0,0x5CE408)
Logon Type: 3



Nov 19 '05 #1
8 3415
Do you have anonymous authentication disabled in IIS?
If so, do you have <authenticati on mode="Windows" /> set in your
web.config?

Nov 19 '05 #2
The easiest way is to turn off anonymous access for the Intranet site. This
will force authentication, usually through a login box (although the network
admins can alleviate this through policy).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"Nils Magnus Englund" wrote:
Hello,

I am having trouble using Integrated Windows Authentication between our
intranet server and our database server, both of which are on our local
domain.

Windows authentication works for our intranet server - my domain user
"DOM\nme" is correctly authenticated and authorized to view the ASP.NET page
on our intranet. The ASP.NET application uses impersonation (<identity
impersonate="tr ue"> in Web.config).

Windows authentication also works for the SQL Server; when logged on to the
domain, I can start Query Analyzer and connect to the SQL Server using
Windows authentication. Permissions on the SQL Server are also correctly set
up.

However, problems arise when I want to connect to the SQL Server from the
ASP.NET page - I get the fairly common error message below:

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

Although I do get a lot of hits when searching for this specific error, I
still can't seem to find the cause of the problem.

The connection string I'm using to connect to the SQL Server is:
"Server=DB;Inte grated Security=SSPI;D atabase=Intrane tDB".

When setting <identity impersonate="fa lse">, I get the error message "Login
failed for user 'DOM\INTRANET$' ." - DOM\INTRANET$ is the hostname of the
intranet server.

In the database servers event log, I can see two events (supplied below)
after trying to authenticate (unsuccessfully ) from the ASP.NET application
to the SQL Server as "DOM\nme".

What do I need to do to let users use Windows authentication against the DB
server as well?
Regards,
Nils Magnus Englund
(event log entries follows...)
Date: 08.08.2005
Source: Security
Time: 15:14:55
Category: Logon/Logoff
Type: Success Audit
Event ID: 540
User: NT AUTHORITY\ANONY MOUS LOGON
Computer: DB

Description:
Successful Network Logon:
User Name:
Domain:
Logon ID: (0x0,0x5CE408)
Logon Type: 3
Logon Process: NtLmSsp
Authentication Package: NTLM
Workstation Name: INTRANET
Logon GUID: -
Caller User Name: -
Caller Domain: -
Caller Logon ID: -
Caller Process ID: -
Transited Services: -
Source Network Address: -
Source Port: -
Date: 08.08.2005
Source: Security
Time: 15:14:55
Category: Logon/Logoff
Type: Success Audit
Event ID: 538
User: NT AUTHORITY\ANONY MOUS LOGON
Computer: DB

Description:
User Logoff:
User Name: ANONYMOUS LOGON
Domain: NT AUTHORITY
Logon ID: (0x0,0x5CE408)
Logon Type: 3



Nov 19 '05 #3
"Stefan" <Cl*********@gm ail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Do you have anonymous authentication disabled in IIS?
If so, do you have <authenticati on mode="Windows" /> set in your
web.config?


In reply to both Stefan and Gregory;

Anonymous authentication is disabled, and I have authentication mode
"Windows" set in Web.config.

Again, let me specify that the Windows authentication for the ASP.NET page
works, and the User.Identity part successfully retrieves the domain user.
It's the Windows authentication to the SQL Server from the ASP.NET page that
causes trouble.
Regards,
Nils Magnus Englund
Nov 19 '05 #4
Nils hae you give your database and table the ASPNET account permission?
Try doing that.
Patrick
"Nils Magnus Englund" <ni************ *****@orkfin.no > wrote in message
news:O7******** ******@TK2MSFTN GP15.phx.gbl...
"Stefan" <Cl*********@gm ail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Do you have anonymous authentication disabled in IIS?
If so, do you have <authenticati on mode="Windows" /> set in your
web.config?
In reply to both Stefan and Gregory;

Anonymous authentication is disabled, and I have authentication mode
"Windows" set in Web.config.

Again, let me specify that the Windows authentication for the ASP.NET page
works, and the User.Identity part successfully retrieves the domain user.
It's the Windows authentication to the SQL Server from the ASP.NET page

that causes trouble.
Regards,
Nils Magnus Englund

Nov 19 '05 #5
Hi Patrick,

Since the database server isn't the same server as the ASP.NET server, and
since ASPNET is a local user, I cannot use that user to set permissions on
the database server. However, because of the identity impersonation, is the
application supposed to be connecting as ASPNET at all?
Regards,
Nils Magnus Englund

"Patrick.O. Ige" <na********@hot mail.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Nils hae you give your database and table the ASPNET account permission?
Try doing that.
Patrick
"Nils Magnus Englund" <ni************ *****@orkfin.no > wrote in message
news:O7******** ******@TK2MSFTN GP15.phx.gbl...
"Stefan" <Cl*********@gm ail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
> Do you have anonymous authentication disabled in IIS?
> If so, do you have <authenticati on mode="Windows" /> set in your
> web.config?


In reply to both Stefan and Gregory;

Anonymous authentication is disabled, and I have authentication mode
"Windows" set in Web.config.

Again, let me specify that the Windows authentication for the ASP.NET
page
works, and the User.Identity part successfully retrieves the domain user.
It's the Windows authentication to the SQL Server from the ASP.NET page

that
causes trouble.
Regards,
Nils Magnus Englund


Nov 19 '05 #6
On Tue, 9 Aug 2005 08:21:08 +0200, "Nils Magnus Englund" <ni************ *****@orkfin.no > wrote:

¤ Hi Patrick,
¤
¤ Since the database server isn't the same server as the ASP.NET server, and
¤ since ASPNET is a local user, I cannot use that user to set permissions on
¤ the database server. However, because of the identity impersonation, is the
¤ application supposed to be connecting as ASPNET at all?
¤

If your ASP.NET app is configured for Integrated Windows security, credentials cannot be delegated
by IIS to the remote database server w/o implementing Kerberos.

The reason for this is that NTLM authenticates credentials under IIS Integrated Windows security so
IIS never receives the credentials and cannot forward them for delegation.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #7
> If your ASP.NET app is configured for Integrated Windows security,
credentials cannot be delegated
by IIS to the remote database server w/o implementing Kerberos.

The reason for this is that NTLM authenticates credentials under IIS
Integrated Windows security so
IIS never receives the credentials and cannot forward them for delegation.

But why can't I use Kerberos authentication? Is it anyway to force the
application to use Kerberos? The WindowsIdentity .Authentication Type property
returns "Negotiate" - this should be "Kerberos", should it not?
Regards,
Nils Magnus Englund
Nov 19 '05 #8
On Tue, 16 Aug 2005 11:35:17 +0200, "Nils Magnus Englund" <ni************ *****@orkfin.no > wrote:

¤ > If your ASP.NET app is configured for Integrated Windows security,
¤ > credentials cannot be delegated
¤ > by IIS to the remote database server w/o implementing Kerberos.
¤ >
¤ > The reason for this is that NTLM authenticates credentials under IIS
¤ > Integrated Windows security so
¤ > IIS never receives the credentials and cannot forward them for delegation.
¤
¤
¤ But why can't I use Kerberos authentication? Is it anyway to force the
¤ application to use Kerberos? The WindowsIdentity .Authentication Type property
¤ returns "Negotiate" - this should be "Kerberos", should it not?
¤

You can use Kerberos, but your environment must be configured for it. The following should help:

http://msdn.microsoft.com/library/de...delegation.asp
http://msdn.microsoft.com/library/de...SecNetHT05.asp
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #9

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

Similar topics

8
3683
by: Bob Everland | last post by:
I have an application that is ISAPI and the only way to secure it is through NT permissions. I need to have a way to login to windows authentication so that when I get to the ISAPI application no boxes come up. I want an ASP page to sit between the user and the ISAPI application. The rest of my application is using authentication that is...
2
2614
by: Joseph Geretz | last post by:
I'm having a credentialing problem in my web application. Actually, I don't think this is an IIS security issue, since I'm able to access the page I'm requesting. However, the executing page itself is not able to access a specific network resource and I just can't figure out why. First of all, let me say this worked fine with IIS running on...
3
4615
by: Reza | last post by:
Hello I tried this friday, but didn't get anywhere so trying again Basically, I have a fixed list of people that can access the application in the Intranet, and with the policy of the company the Users can be created only with Windows authentication in SQL Server - with SQL server authentication have no problem So every time I try to connect...
1
1739
by: Thomas Scheiderich | last post by:
I am having a problem connecting to an Sql Server using Windows Authentication. I am using the following command: server=Raptor;uid=tfs;password=tol1ee;database=ABC;Network Library =dbmssocn This works fine if Sql Server is set up as Sql and Windows Authentication. If I change the Sql Server to Windows Authentication, I get the...
5
2678
by: pberna | last post by:
Dear all, I built a Web Form application to start and stop a Windows Service remotely. I successful tested the application on Windows 2000 server + IIS. I must include the ASPNET user to the Administration group (on server side) to have the necessary authorization to start a Windows Service (I don't understand why "Power User" rights are...
6
4212
by: mcollier | last post by:
I am running a Windows Server 2003 machine as my web server. I would like to use Windows authentication for connections to my SQL Server 2000 instance on a Windows 2000 server. I've read where mirroring the ASPNET account and password on the web server and SQL server would work. However, with IIS 6, ASP.NET runs under the 'NT...
6
7531
by: Kevin Yu | last post by:
is it possible to for user to click a logout button to logout and when the user want to get into the system again, the user have to login again? Kevin
7
3013
by: Alice Wong | last post by:
I am setting up my Web ASP.net application to connect to Sql server using windows authentication. I set up IIS to have integrated windows authenication and sql to allow Windows authentication. And I trun annonymous login. I use this connection to connect. server={0};database={1};Integrated Security=SSPI where {0} servname and {1}...
4
2340
by: Preben Zacho | last post by:
Hi there The scenario I got is this: I have created a Windows application in VS and I want to deploy it to another machine running Windows Vista. Since I have no control over this other machine, I've set it up to run SQL Authentication and I have added a new user called "MyUser" and applied a password. This user/password is used in my...
0
7615
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...
0
7819
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. ...
1
7581
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...
0
7897
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...
0
6170
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...
1
5446
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...
0
3589
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...
0
3566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1149
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.