473,385 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

IIS & SQL Issues

I am trying to use integrated Windows authentication and
impersonation to run a page that accesses SQL Server via integrated
security. It's not working -- sort of. I've set IIS security to
integrated Windows authentication (and unchecked the other options).
I've set the web.config to use Windows authentication and set
impersonation to true. The connection string includes Integrated
Security = SSPI. And it works... if you access the page from the same
machine. If you call the page over the network (even when logged in
under the same Windows account as when on the server), it fails with
the "Login failed for user '(null)'" error. I display the results of
Environment.UserName on the page (commenting out the sql connection
code so that it will run when calling it over the network), and in all
cases it shows the correct username. (I call the page over the network
and sure enough it displays my account name.)
Nov 18 '05 #1
4 1105
Ok, you've misunderstood what integrated authentication is.

When the integrated authentication check box is the only box checked on a
web site that means that only computer accounts created on the server that
have been given access to the folder the web site files are stored in may
run the website.

When you are using windows authentication in conjunction with sql server
here is what you should do:

1. Create an account on the server (or domain) which is specifically for
the web site to use.
2. In IIS right click on the web site and choose properties and then
click on the directory security tab. Click on the Edit button. Now LEAVE the
anonymous access checkbox checked. Click the Browse button. Set the web site
to run under the account you created for it.
3. In Sql Server add the same account you created for the web site to run
as to sql server and give that account the appropriate permissions to the
database.
4. Set the site to use the account the web site is running for accessing
the database by placing the tag:
<identity impersonate="true" /> into the web.config file

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"TipTop" <ab*****@speakeasy.net> wrote in message
news:et********************************@4ax.com...
I am trying to use integrated Windows authentication and
impersonation to run a page that accesses SQL Server via integrated
security. It's not working -- sort of. I've set IIS security to
integrated Windows authentication (and unchecked the other options).
I've set the web.config to use Windows authentication and set
impersonation to true. The connection string includes Integrated
Security = SSPI. And it works... if you access the page from the same
machine. If you call the page over the network (even when logged in
under the same Windows account as when on the server), it fails with
the "Login failed for user '(null)'" error. I display the results of
Environment.UserName on the page (commenting out the sql connection
code so that it will run when calling it over the network), and in all
cases it shows the correct username. (I call the page over the network
and sure enough it displays my account name.)

Nov 18 '05 #2
It's called the "double hop" issue and happens if the SQL Server is not on
the same computer as IIS (if they are on the same computer it should work -
it works for me).
Here is one article on it, search google for "double hop" and you should get
more.
http://weblogs.asp.net/nunos/archive.../12/88468.aspx

"TipTop" <ab*****@speakeasy.net> wrote in message
news:et********************************@4ax.com...
I am trying to use integrated Windows authentication and
impersonation to run a page that accesses SQL Server via integrated
security. It's not working -- sort of. I've set IIS security to
integrated Windows authentication (and unchecked the other options).
I've set the web.config to use Windows authentication and set
impersonation to true. The connection string includes Integrated
Security = SSPI. And it works... if you access the page from the same
machine. If you call the page over the network (even when logged in
under the same Windows account as when on the server), it fails with
the "Login failed for user '(null)'" error. I display the results of
Environment.UserName on the page (commenting out the sql connection
code so that it will run when calling it over the network), and in all
cases it shows the correct username. (I call the page over the network
and sure enough it displays my account name.)

Nov 18 '05 #3
a) if you do this, you will lose the benefits of connection pooling, as a
separate connection will be used for each security context (each user
account will have it's own pool). So, this solution will not scale to a
large number of users. It's OK if you have a small number of users

b) the problem is double-hop authentication. When using IWA, the webserver
does not have the user's password. It just gets a token from the DC, but the
token does not have permission to logon to network resources.

Options:
a) if you are using a Windows 2000 Domain, you can enable delegation. This
allows the IIS server to impersonate the Windows account, and logon to the
backend SQL Server. You need to use Kerberos authentication for this (not
NTLM v2)

b) if you are using a Windows 2003 Domain, when you enable constrained
delegation, you can use Protocol Transition. This allows the user to
authenticate using any of a number of mechanisms to the IIS server (eg
Digest, or NTLM), and the webserver can still get an Kerberos token to logon
to the SQL Server.

Here are a few articles to get you started:

IMPORTANT:
Read chapter 12 from the Building Secure ASP.Net Application Book - it has
very good information about building scalable, secure ASP.Net applications
(eg using a trusted subsystem model):
http://msdn.microsoft.com/library/de...asp?frame=true

http://support.microsoft.com/?id=319723
INF: SQL Server 2000 Kerberos support including SQL Server virtual servers
on server clusters

http://support.microsoft.com/default...b;en-us;810572
HOW TO: Configure an ASP.NET Application for a Delegation Scenario

http://support.microsoft.com/?id=294382
Authentication May Fail with "401.3" Error If Web Site's "Host Header"
Differs from Server's NetBIOS Name

http://support.microsoft.com/default.aspx?kbid=325894
HOW TO: Configure Computer Accounts and User Accounts So That They Are
Trusted for Delegation in Windows Server 2003 Enterprise Edition (also
includes Windows 2000 instructions)

http://www.microsoft.com/resources/d...l_computer.asp
Configuring Users and Computers for delegation (there's a couple of pages -
use the links in the nav bar to get to them)

Windows 2003 Protocol Transition
http://www.microsoft.com/technet/pro.../constdel.mspx

Cheers
Ken

"TipTop" <ab*****@speakeasy.net> wrote in message
news:et********************************@4ax.com...
: I am trying to use integrated Windows authentication and
: impersonation to run a page that accesses SQL Server via integrated
: security. It's not working -- sort of. I've set IIS security to
: integrated Windows authentication (and unchecked the other options).
: I've set the web.config to use Windows authentication and set
: impersonation to true. The connection string includes Integrated
: Security = SSPI. And it works... if you access the page from the same
: machine. If you call the page over the network (even when logged in
: under the same Windows account as when on the server), it fails with
: the "Login failed for user '(null)'" error. I display the results of
: Environment.UserName on the page (commenting out the sql connection
: code so that it will run when calling it over the network), and in all
: cases it shows the correct username. (I call the page over the network
: and sure enough it displays my account name.)
:
:
Nov 18 '05 #4
Hi all,

I am having this problem also, but unfortunately company policy prohibits me
from changing the accounts policy. So far to solve this problem I have
disabled anonymous access in IIS and have enabled the integrated windows
authentication, both in IIS and my web.config. I then changed on the IIS 6.0
box the default worker process to run as a low privileged domain account
user. I then added this account to have r\w permissions on the sql database.
I then have disabled impersonation, this so far looks only to be the most
appropriate solution.

"TipTop" <ab*****@speakeasy.net> wrote in message
news:et********************************@4ax.com...
I am trying to use integrated Windows authentication and
impersonation to run a page that accesses SQL Server via integrated
security. It's not working -- sort of. I've set IIS security to
integrated Windows authentication (and unchecked the other options).
I've set the web.config to use Windows authentication and set
impersonation to true. The connection string includes Integrated
Security = SSPI. And it works... if you access the page from the same
machine. If you call the page over the network (even when logged in
under the same Windows account as when on the server), it fails with
the "Login failed for user '(null)'" error. I display the results of
Environment.UserName on the page (commenting out the sql connection
code so that it will run when calling it over the network), and in all
cases it shows the correct username. (I call the page over the network
and sure enough it displays my account name.)

Nov 18 '05 #5

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

Similar topics

65
by: perseus | last post by:
I think that everyone who told me that my question is irrelevant, in particular Mr. David White, is being absolutely ridiculous. Obviously, most of you up here behave like the owners of the C++...
5
by: Qazz | last post by:
Yesterday morning, all the ASP Reference Pages were there, and then yesterday afternoon they were all gone!!! For example:...
1
by: Megan | last post by:
quick summary: i'm having problems trying to group fields in a report in order to calculate percentages. to calculate percentages, i'm comparing the results from my grouped fields to the totals....
4
by: L2XL | last post by:
I have an ASP.NET (VB) app that I created for the Windows and IE6 enviroment. When it runs under Firefox on Windows it looks similar but has some display issues. When I run it under Firefox on...
9
by: Jimmy | last post by:
Hello, If I want to check in C# code that if there is a & in my string variable using RegExp, how should I inform RegExp about &-char? Is just &, \&, &amp; or something else? I have strucled with...
13
by: Ragnar | last post by:
Hi, 2 issues left with my tidy-work: 1) Tidy transforms a "&amp;" in the source-xml into a "&" in the tidied version. My XML-Importer cannot handle it 2) in a long <title>-string a wrap is...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
42
by: coder_lol | last post by:
Thanks everyone again for contributing to helping me clear C++ confusions. I did some serious reading on copy constructors and assignments and I think I've got a good handle on the memory stuff. ...
0
by: ketakijoshi | last post by:
Hi, I am pretty new to C# .Net. Working on a piece of code where I have converted Chinese characters into hex equivalents. But when I insert it in the XML, the "&" sign is converted into the "&amp;"...
5
by: Nike1984 | last post by:
I'm fairly new to Javascript and it's more of a guessing game for me... I'm trying to build an app for Google Maps and just had some issues recently. First off I just wanted to say that everything...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.