« Previous Next »

Thread: aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

Last post 09-28-2009 10:09 PM by lextm. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 09-25-2009, 6:02 PM

    aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

    Hi,

     I'm quite new to IIS and asp.

     I am writing a webpage using asp.net (c#) and setting up a webserver using ISS 5. The web form is accessing an MSSQL2005 database on another box, using windows authentication login.

     

     When I test the webform locally by using "View in browser" in visual studio, a .net Development Server is automatically setup, and the page is accessing the database with no problem.

     

    However, when I set the website using ISS, and access the web form I created through ISS's localhost address, I always get this sql connection error: 

    "Login failed for user ''. The user is not associated with a trusted SQL Server connection. "

     

    The two methods are using the exactly same connection string: 

    "Data Source=aaaaa;Initial Catalog=DevTrackIssues;Integrated Security=SSPI;"

     

    My ISS is set to not allow anonymous users and use Windows authentication in "Directory security".

     

    Thanks so much in advance.

  • 09-25-2009, 8:32 PM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 12:18 AM
    • Shanghai, PRC
    • Posts 1,413

    Re: aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

    First, IIS has a total different security model compared to the simple and easy ASP.NET Development Server.

    Second, you need to study ASP.NET impersonation and delegation, as they are required when you have IIS and SQL Server on two different servers,

    http://msdn.microsoft.com/en-us/library/ms998351.aspx

    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 09-28-2009, 9:56 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Central NJ
    • Posts 6,235
    • IIS MVPs

    Re: aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

  • 09-28-2009, 10:17 AM In reply to

    Re: aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

    Hi,

     

    thanks for the replies. I was able to find the answer on how to setup IIS.

     Cheers!

     

    Zuck

  • 09-28-2009, 5:39 PM In reply to

    Re: aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

    Well, this is partially solved. 

     The new problem:

    I was able to let the clients get access to Mssql server by forcing them to enter their windows authentication. (checked the "Basic authentication" option in IIS setting, but no others.)

    However, I still cannot find a way to always use my own Windows Authentication (on IIS server machine) to logon to Mssql. 

     Basically, I don't know how to get the windows authentication token from the IIS machine. the following code always gets the windows logon from the client:

     

    IntPtr logonToken = WindowsIdentity.GetCurrent().Token;       
    WindowsIdentity wi = new WindowsIdentity  (logonToken);

    WindowsImpersonationContext ctx = null;

    ctx = wi.Impersonate();

     

    Web.Config also enables the following:

         <authentication mode="Windows"/>
        <identity impersonate="true"/>

    Can someone please enlighten me please?

    Thansk again!

  • 09-28-2009, 10:09 PM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 12:18 AM
    • Shanghai, PRC
    • Posts 1,413

    Re: aspx on IIS 5.0 accessing MSSQL Windows Authentication Failure

    Basic authentication always supports delegation and that's why it works. I don't know what is "always use my own Windows Authentication". That's really a weird term. I hope you can spare enough time to go through the article I posted before and carefully do some experiments to master the details. Unless you get a good understanding of the topic, you can make it work as you expected.
    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (6 items)
Microsoft Communities