problem with trusted connection (asp.net)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mad Scientist Jr

    problem with trusted connection (asp.net)

    I am getting the following error when trying to access a database with
    a trusted connection:

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

    My connection string is:

    "Server=MyServe r; Database=MyCata log; Trusted_Connect ion=True;"

    Note that Anonymous Access is off in IIS, and I am able to read my
    Windows login with:

    Textbox1.text =
    System.Web.Http Context.Current .User.Identity. Name.Substring( System.Web.Http Context.Current .User.Identity. Name.IndexOf("\ ")
    + 1).ToLower()

    Can anyone explain how to query the db using a trusted connection?

    PS Is there a way to dynamically retrieve a list of databases the
    current user has SQL rights on, by specifying only the server, again
    using trusted connection?

    Thanks...

  • Hari Prasad

    #2
    Re: problem with trusted connection (asp.net)

    Hello,

    Have you added the OS user into the SQL Server? If not add the particular
    user into SQL Server Logins and try connecting.

    Thanks
    Hari




    "Mad Scientist Jr" <usenet_daughte r@yahoo.comwrot e in message
    news:1163550792 .558431.311470@ k70g2000cwa.goo glegroups.com.. .
    >I am getting the following error when trying to access a database with
    a trusted connection:
    >
    "Login failed for user '(null)'. Reason: Not associated with a trusted
    SQL Server connection."
    >
    My connection string is:
    >
    "Server=MyServe r; Database=MyCata log; Trusted_Connect ion=True;"
    >
    Note that Anonymous Access is off in IIS, and I am able to read my
    Windows login with:
    >
    Textbox1.text =
    System.Web.Http Context.Current .User.Identity. Name.Substring( System.Web.Http Context.Current .User.Identity. Name.IndexOf("\ ")
    + 1).ToLower()
    >
    Can anyone explain how to query the db using a trusted connection?
    >
    PS Is there a way to dynamically retrieve a list of databases the
    current user has SQL rights on, by specifying only the server, again
    using trusted connection?
    >
    Thanks...
    >

    Comment

    • Damien

      #3
      Re: problem with trusted connection (asp.net)

      Mad Scientist Jr wrote:
      I am getting the following error when trying to access a database with
      a trusted connection:
      >
      "Login failed for user '(null)'. Reason: Not associated with a trusted
      SQL Server connection."
      >
      My connection string is:
      >
      "Server=MyServe r; Database=MyCata log; Trusted_Connect ion=True;"
      >
      Note that Anonymous Access is off in IIS, and I am able to read my
      Windows login with:
      >
      Textbox1.text =
      System.Web.Http Context.Current .User.Identity. Name.Substring( System.Web.Http Context.Current .User.Identity. Name.IndexOf("\ ")
      + 1).ToLower()
      >
      Can anyone explain how to query the db using a trusted connection?
      >
      PS Is there a way to dynamically retrieve a list of databases the
      current user has SQL rights on, by specifying only the server, again
      using trusted connection?
      >
      Thanks...
      You're almost certainly encountering the "double hop" issue. This
      arises when IIS and SQL Server are on separate servers. If that isn't
      true in your circumstance, then ignore the rest of this post.

      The problem arises because your client machine authenticates you to the
      IIS server, but the IIS server has no means of authenticating you to
      the SQL Server box (It can't make the second "hop" of authentication) .
      There was a superb MSDN Magazine article some time back that describes
      this, but I can't seem to find it right now. I have found this
      knowledge base article:



      which seems to cover the same areas.

      Damien

      Comment

      • Mad Scientist Jr

        #4
        Re: problem with trusted connection (asp.net)

        Thanks for your reply...

        I read up on it and fixed the problem on my local machine by adding the
        following to my web.config file:

        <identity impersonate="tr ue"/>

        However when I try running this on the live web server I get this
        error:

        Login failed for user 'NT AUTHORITY\ANONY MOUS LOGON'.

        Any ideas?


        You're almost certainly encountering the "double hop" issue. This
        arises when IIS and SQL Server are on separate servers. If that isn't
        true in your circumstance, then ignore the rest of this post.
        >
        The problem arises because your client machine authenticates you to the
        IIS server, but the IIS server has no means of authenticating you to
        the SQL Server box (It can't make the second "hop" of authentication) .


        Damien wrote:
        Mad Scientist Jr wrote:
        >
        I am getting the following error when trying to access a database with
        a trusted connection:

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

        My connection string is:

        "Server=MyServe r; Database=MyCata log; Trusted_Connect ion=True;"

        Note that Anonymous Access is off in IIS, and I am able to read my
        Windows login with:

        Textbox1.text =
        System.Web.Http Context.Current .User.Identity. Name.Substring( System.Web.Http Context.Current .User.Identity. Name.IndexOf("\ ")
        + 1).ToLower()

        Can anyone explain how to query the db using a trusted connection?

        PS Is there a way to dynamically retrieve a list of databases the
        current user has SQL rights on, by specifying only the server, again
        using trusted connection?

        Thanks...
        >
        You're almost certainly encountering the "double hop" issue. This
        arises when IIS and SQL Server are on separate servers. If that isn't
        true in your circumstance, then ignore the rest of this post.
        >
        The problem arises because your client machine authenticates you to the
        IIS server, but the IIS server has no means of authenticating you to
        the SQL Server box (It can't make the second "hop" of authentication) .
        There was a superb MSDN Magazine article some time back that describes
        this, but I can't seem to find it right now. I have found this
        knowledge base article:
        >

        >
        which seems to cover the same areas.
        >
        Damien

        Comment

        Working...