Question

Cannot authenticate to sql server through asp.net project upon moving project to 2003 server.

Asked by: bkhendershot

Hello,
 
I have an asp.net application written in vb that uses windows integrated authentication.  The application was originally written on an 2000 server machine running IIS 5 for development.  I have the web.config set to use authentication "Windows" and Impersonate="true".  I have the development server set to be trusted for delegation to talk to the sql server.  Everything worked just wonderfully.

Now I've copied the application over to our live server running 2003 server and IIS 6.0, enabled the live server for delegation, rebooted and the app no longer works.  I just keep getting the "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection." error.

I dont know if I've missed a step or if something is different in 2003 server or IIS 6.0 ... I've been looking online all day and cannot find anything.  Can someone please help?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-01-28 at 13:26:40ID21293175
Tags

sql

,

server

,

authenticate

Topic

Windows Network Security

Participating Experts
1
Points
250
Comments
25

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Urgent-ASP.NET impersonation
    We have an ASP.NET application,which invoked a webservice. The webservice in turns uses a c# library to do the business processing. The ASP.NET client has been configured as requiring "integrated windows authentication" in IIS.Additionally the web.config contains im...
  2. impersonation
    I want to use impersonation for my web app. I know that I can put: <identity impersonate="true" username=.. password=...> in the web.config file. Is there a way to achieve this without putting the password in the web.config file?
  3. Impersonation problem
    Hi, I want to get ASP.NET to impersonate a user in the Active Directory using thier login credentials. When someone goes to a page on our company intranet they should not have to log into the site if they are logged into the Active Directory already. Also I want to control ac...
  4. Impersonation Without Storing Password in Web.Config Fil…
    Hi, Is there any way Impersonation can be used, without storing the username / password in plain text in the Web.Config file. Would essentially like to encrypt this information. Thanks

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Dave_DietzPosted on 2005-01-28 at 22:49:07ID: 13170322

What UserID is the Application pool running as that contains your application?

Dave Dietz

 

by: bkhendershotPosted on 2005-01-31 at 13:52:29ID: 13187435

Dave,
   I am pretty new to .net.  Is this the user that you set in IIS for the app to run as?  I put it on a user with admin rights just to see if I could get it to work that way.  Still get the error.
   Thanks,
      ~~Kim

 

by: Dave_DietzPosted on 2005-01-31 at 16:58:35ID: 13188578

Yes.

The UserID *must* be a member of the IIS_WPG group for the applciation pool to start.
Additionally, the UserID must have appropriate SPNs set for Kerberos Authentication Delegation to work properly.

What I would suggest is to change the Application Pool to use Network Service for the time being - this will allow it to use the auto generated SPNs of the server.

In your question you said the dev server was trusted for delegation.  Is the live server trusted as well?  This will not work if it isn't.

Dave Dietz

 

by: bkhendershotPosted on 2005-02-01 at 05:28:41ID: 13192203

What is the IIS_WPG Group?  I didnt do anything with that on the development server?
I have SPN's set for the sql server, but didnt know had to do that with the user as well?  How can I do that?

Also, dont know how to set app pool to use Network service...?

The live server IS trusted for delegation.

Thanks for helping.

~~Kim

 

by: bkhendershotPosted on 2005-02-08 at 06:05:25ID: 13254030

can anyone give me a little more details on this?

 

by: Dave_DietzPosted on 2005-02-08 at 10:21:30ID: 13256889

The IIS_WPG group is a group that is given proper permissions to particular resources to be able to be used as the identity of an Application Pool.

By default System, Local Service, Network Service and IWAM_<machinename> are in this group.  If you want to run the app pool as a user not included here you must add them to the group.

To set an SPN for a user you use the SetSPN utility with a command line similar to the following:

 SetSPN -A http/hostheadername domain\userid

where hostheadername is the name you use to access the website and domain\userid is the doamin and name of the account the application pool runs as.

To set the AppPool to run as Network Service you simply open the properties on the AppPool, go to the identity tab, select the Predefined radio button and select Network Service on the dropdown.

Enoguh details for now? :-)

Dave Dietz

 

by: bkhendershotPosted on 2005-02-18 at 13:03:24ID: 13349715

Thank you - I thought I was making progress, but now I'm not.  I found an article that showed how to give the IIS_WPG group permission on SQL.  I did that yesterday before going home.  Now today, that group is no longer listed under Security in SQL - and when I try to re-add it, it tells me the group does not exist.

The program IS running under the default application pool.

What am I doing wrong??

 

by: bkhendershotPosted on 2005-02-18 at 13:12:49ID: 13349799

OK - Yesterday I added to SQL networkdomain\iis_wpg
It wont let me add IIS_server\iis_wpg b/c it says it does not exist.  Ican browse and select it using the ellipse button.  Just when I try to save it wont let me.  

 

by: bkhendershotPosted on 2005-03-15 at 12:06:51ID: 13548333

I have gone through each step listed on this page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskAccessingSQLServerUsingWindowsIntegratedSecurity.asp

* IIS Directory Security is listed as Windows Integrated.  Anonymous Access is not enabled.
* Web.Config file includes the following :
   <authentication mode="Windows">
   </authentication>
    <authorization>
        <allow users="*" />
   </authorization>
   <identity impersonate="true" />
* Web.Config also includes connection string :
     <appSettings>  
      <add key="ConnectionString" value="data source=Sql-Server;Trusted_Connection=Yes;initial catalog=Northwind;integrated security=SSPI;persist security info=False;workstation id=Web-Server;packet size=4096;Network Library=dbmssocn"/>
    </appSettings>
*   Web Server is trusted for Kerberos Delegation
*   Application is running in the Default App Pool as Network Service

The only thing I didn't fully understand in the article was configuring SQL Server...

"To configure SQL Server for Windows integrated security
From the Windows Start menu, choose Microsoft SQL Server, and then choose Enterprise Manager.
Open the node for the server and expand the node for the database you want to give users permissions for.
Right-click the Users node and choose New Database User.
In the Database User Properties dialog box, enter domain\username in the Login name box, and then click OK. Alternatively, configure the SQL Server to allow all domain users to access the database. "

I didnt do anything with this for the development site, but went ahead and added "domain/primary-group" to have permissions to the database in SQL.

After all of this, I still get the "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection." error.

SQL Server is Windows 2003 Server running SQL 2000
Web Server is Windows 2003 Server running IIS 6
Domain Controller with Active Directory is Windows 2003 Server
Application is written with .NET Framework 1.1 ASP.NET (VB)

The only difference between the working development site and the non working live site is the development site uses a Windows 2000 Professional machine as a "web server".

This doesn't seem like it should be overly complicated to set up.  After days of researching, checking, trying different things, I find it pretty frustrating that still nothing works.  I am completely at a loss.

Any suggestions or help, please??

Thanks,
   ~~Kim

 

by: bkhendershotPosted on 2005-03-15 at 12:08:15ID: 13548350

also - i am under the impression that with the application running as Network Service, I dont have to set up any SPN's or do anything with the IIS_WPG group.  Is that correct?
  ~~Kim

 

by: Dave_DietzPosted on 2005-03-15 at 13:18:56ID: 13549087

Is SQL Server running as local system or as a specified user?

Dave Dietz

 

by: bkhendershotPosted on 2005-03-15 at 13:21:28ID: 13549114

I dont know ..... where do you check this at?

 

by: bkhendershotPosted on 2005-03-22 at 08:38:11ID: 13602884

Under Sql Server Properties, Security tab

Authentication selected is "SQL Server and Windows"
Start and run SQL server is "This Account".  

The domain/username there is added as a user to SQL Security that does have permission to the database I'm trying to get to.

Is that what you were asking?

I believe those settings are like that for another windows based application that is used company wide.

 

by: bkhendershotPosted on 2005-03-22 at 08:59:23ID: 13603145

If it's a SQL issue, why is the error login failed for user "NULL" instead of my username?

 

by: Dave_DietzPosted on 2005-03-22 at 10:29:19ID: 13604141

Yes, that is what I was looking for.

Since SQL is not running as the System account it has to have an SPN registered for it for Kerberos to work properly.

The following article explains this:

811889 How to troubleshoot the "Cannot generate SSPI context" error message
http://support.microsoft.com/?id=811889

The reason you are seeing the user NULL is that when you try to use NTLM instead of Kerberos there are no credentials passed at all.

Dave Dietz

 

by: bkhendershotPosted on 2005-03-22 at 10:59:48ID: 13604488

The user it's running as has full administrator rights - shouldn't it then be able to create it's own SPN?

Quote the article :
"If you test using a domain administrator account as the SQL Server service account, the SPN is successfully created because the domain administrator-level credentials that you must have to create an SPN are present."

 

by: bkhendershotPosted on 2005-03-22 at 11:01:27ID: 13604504

Also, in an earlier post you said if the site uses Network Service, it would use automatic SPNs.. ?

 

by: Dave_DietzPosted on 2005-03-22 at 14:58:40ID: 13606672

The user it runs as would have to have Domain Admin rights since registering an SPN makes a modification to Active Directory.  Local Admins do not have the proper permissions to modify these AD settings.

The earlier comment regarding the Network Service account has to do with the SPNs on the *web* server.  Now I am thinking that the issue has more to do with the SPNs on the *SQL* server - both have to be set correctly for auth delegation to work.

Dave Dietz

 

by: bkhendershotPosted on 2005-06-08 at 05:50:08ID: 14170069

After trying all of the above steps my question has still not been answered and a solution has not been found.

We can keep the question up and keep trying to find a solution or just delete it.  Whatever anyone would like to do is fine with me.

~~Kim

 

by: Dave_DietzPosted on 2005-06-08 at 16:48:57ID: 14175656

You set an SPN on the SQL Server?

Dave Dietz

 

by: bkhendershotPosted on 2005-06-09 at 07:27:35ID: 14180091

No.  I do not know how to set the spns.  

I downloaded a setspn program from microsoft and followed their directions on how to do it http://support.microsoft.com/default.aspx?scid=kb;en-us;319723 on this article.  When i try to run any "SetSPN" commands through the command prompt I get an error that "setspn is not recognized as an internal or external command, program, or batch file."

SQL shouldn't be running as a local admin, if i'm looking in the right place in SQL, right click the server --> Properties --> "Start and Run SQL in the following account", the account there is the domain administrator acount, which from anything I've read it should have permissions to create its own SPNs .. ?

I even tried to put a plain .aspx page in that project that doesn't have any database access and I can't even access that.  I changed impersonation to false in web config to see what i would get and now i get login failed for user DOMAIN\WEBSERVER$ .

I still dont understand why SQL is the problem when it's the same SQL server that the application runs with and talks to when the application was on our development server.

 

by: bkhendershotPosted on 2005-06-09 at 07:30:03ID: 14180115

You said i was getting login failed for user NULL b/c of using NTLM auth instead of Kerberos .... why is it using NTLM?

 

by: Dave_DietzPosted on 2005-06-09 at 08:26:30ID: 14180718

It's using NTLM because there's something not configured right for Kerbros Delegation.

If all the pieces aren't right Kerberos will not work and you'll use NTLM instead which cannot be used for Authentication Delegation.

The SPNs have to be configured correctly on the Web Server and the SQL Server.
DNS has to resolve the names properly.
AD Entries for the computer accounts have to be configured correctly.
Etc...

Look at the following article:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;326985

This will help determine if the problem is that Kerberos isn't working between the client and the web server or if it is failing between the web server and the SQL server....

Dave Dietz

 

by: bkhendershotPosted on 2005-06-10 at 07:58:55ID: 14189259

the .net gods have finally smiled upon me!!  It was the spns.

THANK YOU THANK YOU THANK YOU Dave for your patience and for helping me FINALLY solve this issue.
~~Kim

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...