trusted sql server connection problem!?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Henry

    #1

    trusted sql server connection problem!?

    I an trying to connect to a sql server in asp.net with the sql connection
    object, and every time i try to open the connection i get this


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

    why am i getting this? and how do i get around it? I am logged into the
    domain on the machine that the asp.net system is on, the sql server is a
    seperate machine... vs.net can do a preview of the data and read it in
    vs.net ide, and i can connect and retrieve data using the server explorer,
    but when i do it programaticly it gives me that error... here is my
    connection sub...


    Private dbconnectionstr ing As String = "workstatio n id=DELL5100;pac ket
    size=4096;integ rated security=SSPI;d ata source=BENE-SQL;persist security
    info=False;init ial catalog=ReschIn tranet"
    Public dbconnection As New SqlClient.SqlCo nnection(dbconn ectionstring)


  • Greg

    #2
    Re: trusted sql server connection problem!?

    confirm what account the web app is using to log into sql server. Its been
    a while since I did any asp.net, but I recall this being an issue then and
    we had to make sure the 'asp.net user' could log into sql server...or
    something along those lines.
    "Brian Henry" <brianiup@adelp hia.net> wrote in message
    news:eC8omznkDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I an trying to connect to a sql server in asp.net with the sql connection
    > object, and every time i try to open the connection i get this
    >
    >
    > Server Error in '/' Application.
    > Login failed for user '(null)'. Reason: Not associated with a trusted SQL
    > Server connection.
    >
    > why am i getting this? and how do i get around it? I am logged into the
    > domain on the machine that the asp.net system is on, the sql server is a
    > seperate machine... vs.net can do a preview of the data and read it in
    > vs.net ide, and i can connect and retrieve data using the server explorer,
    > but when i do it programaticly it gives me that error... here is my
    > connection sub...
    >
    >
    > Private dbconnectionstr ing As String = "workstatio n id=DELL5100;pac ket
    > size=4096;integ rated security=SSPI;d ata source=BENE-SQL;persist security
    > info=False;init ial catalog=ReschIn tranet"
    > Public dbconnection As New SqlClient.SqlCo nnection(dbconn ectionstring)
    >
    >[/color]


    Comment

    • Marina

      #3
      Re: trusted sql server connection problem!?

      This is because during development, it is using your integrated security
      authentication to connect to the database.

      At run time, ASPNET is what's trying to connect, and it is not associated
      with a trusted connection.

      So you can either set up ASPNET as a user with rights, or just use a
      username/password account and pass that in to sql server when trying to
      connect.

      "Brian Henry" <brianiup@adelp hia.net> wrote in message
      news:eC8omznkDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
      > I an trying to connect to a sql server in asp.net with the sql connection
      > object, and every time i try to open the connection i get this
      >
      >
      > Server Error in '/' Application.
      > Login failed for user '(null)'. Reason: Not associated with a trusted SQL
      > Server connection.
      >
      > why am i getting this? and how do i get around it? I am logged into the
      > domain on the machine that the asp.net system is on, the sql server is a
      > seperate machine... vs.net can do a preview of the data and read it in
      > vs.net ide, and i can connect and retrieve data using the server explorer,
      > but when i do it programaticly it gives me that error... here is my
      > connection sub...
      >
      >
      > Private dbconnectionstr ing As String = "workstatio n id=DELL5100;pac ket
      > size=4096;integ rated security=SSPI;d ata source=BENE-SQL;persist security
      > info=False;init ial catalog=ReschIn tranet"
      > Public dbconnection As New SqlClient.SqlCo nnection(dbconn ectionstring)
      >
      >[/color]


      Comment

      • Jim Butler

        #4
        Re: trusted sql server connection problem!?

        or what we do here, is switch the web site to run on itegrated security
        (assuming working locally), then it will pass your credentials. also, you
        will need to set the identity impersonate=tru e in the web.config.

        jim
        "Brian Henry" <brianiup@adelp hia.net> wrote in message
        news:eC8omznkDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
        > I an trying to connect to a sql server in asp.net with the sql connection
        > object, and every time i try to open the connection i get this
        >
        >
        > Server Error in '/' Application.
        > Login failed for user '(null)'. Reason: Not associated with a trusted SQL
        > Server connection.
        >
        > why am i getting this? and how do i get around it? I am logged into the
        > domain on the machine that the asp.net system is on, the sql server is a
        > seperate machine... vs.net can do a preview of the data and read it in
        > vs.net ide, and i can connect and retrieve data using the server explorer,
        > but when i do it programaticly it gives me that error... here is my
        > connection sub...
        >
        >
        > Private dbconnectionstr ing As String = "workstatio n id=DELL5100;pac ket
        > size=4096;integ rated security=SSPI;d ata source=BENE-SQL;persist security
        > info=False;init ial catalog=ReschIn tranet"
        > Public dbconnection As New SqlClient.SqlCo nnection(dbconn ectionstring)
        >
        >[/color]


        Comment

        • Cowboy \(Gregory A. Beamer\)

          #5
          Re: trusted sql server connection problem!?

          As you are using integrated security, you will want to do one of the
          following:

          1. Assign the IUSR account rights to the database (bad idea, but easy)
          2. Change to mixed mode security (better, and still quite easy)
          3. Create a user account to access the SQL Server and have the data routines
          assume that identity when calling the database (programming heavy)
          4. Restrict the web app to accounts that have permission to use SQL Server
          in your domain (will not work for Internet apps)

          The IDE runs under your account, the web app runs under IUSR unless you
          restrict it.

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

          *************** *************** *************** *************** **********
          Think Outside the Box!
          *************** *************** *************** *************** **********
          "Brian Henry" <brianiup@adelp hia.net> wrote in message
          news:eC8omznkDH A.2772@TK2MSFTN GP10.phx.gbl...[color=blue]
          > I an trying to connect to a sql server in asp.net with the sql connection
          > object, and every time i try to open the connection i get this
          >
          >
          > Server Error in '/' Application.
          > Login failed for user '(null)'. Reason: Not associated with a trusted SQL
          > Server connection.
          >
          > why am i getting this? and how do i get around it? I am logged into the
          > domain on the machine that the asp.net system is on, the sql server is a
          > seperate machine... vs.net can do a preview of the data and read it in
          > vs.net ide, and i can connect and retrieve data using the server explorer,
          > but when i do it programaticly it gives me that error... here is my
          > connection sub...
          >
          >
          > Private dbconnectionstr ing As String = "workstatio n id=DELL5100;pac ket
          > size=4096;integ rated security=SSPI;d ata source=BENE-SQL;persist security
          > info=False;init ial catalog=ReschIn tranet"
          > Public dbconnection As New SqlClient.SqlCo nnection(dbconn ectionstring)
          >
          >[/color]


          Comment

          • Angel Saenz-Badillos[MS]

            #6
            Re: trusted sql server connection problem!?

            Very nice description, in general Windows Authentication is better than
            Mixed Mode for security reasons.

            You should not be using ado.net for internet apps if you are concerned about
            security, making your Server visible to the internet may not be the best
            idea and users will be able to get the username/password you build into any
            program you distribute.

            --
            Angel Saenz-Badillos [MS] Managed Providers
            This posting is provided "AS IS", with no warranties, and confers no rights.
            Please do not send email directly to this alias. This alias is for newsgroup
            purposes only.

            "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamM> wrote in
            message news:#kJBJFpkDH A.2012@TK2MSFTN GP12.phx.gbl...[color=blue]
            > As you are using integrated security, you will want to do one of the
            > following:
            >
            > 1. Assign the IUSR account rights to the database (bad idea, but easy)
            > 2. Change to mixed mode security (better, and still quite easy)
            > 3. Create a user account to access the SQL Server and have the data[/color]
            routines[color=blue]
            > assume that identity when calling the database (programming heavy)
            > 4. Restrict the web app to accounts that have permission to use SQL Server
            > in your domain (will not work for Internet apps)
            >
            > The IDE runs under your account, the web app runs under IUSR unless you
            > restrict it.
            >
            > --
            > Gregory A. Beamer
            > MVP; MCP: +I, SE, SD, DBA
            >
            > *************** *************** *************** *************** **********
            > Think Outside the Box!
            > *************** *************** *************** *************** **********
            > "Brian Henry" <brianiup@adelp hia.net> wrote in message
            > news:eC8omznkDH A.2772@TK2MSFTN GP10.phx.gbl...[color=green]
            > > I an trying to connect to a sql server in asp.net with the sql[/color][/color]
            connection[color=blue][color=green]
            > > object, and every time i try to open the connection i get this
            > >
            > >
            > > Server Error in '/' Application.
            > > Login failed for user '(null)'. Reason: Not associated with a trusted[/color][/color]
            SQL[color=blue][color=green]
            > > Server connection.
            > >
            > > why am i getting this? and how do i get around it? I am logged into the
            > > domain on the machine that the asp.net system is on, the sql server is a
            > > seperate machine... vs.net can do a preview of the data and read it in
            > > vs.net ide, and i can connect and retrieve data using the server[/color][/color]
            explorer,[color=blue][color=green]
            > > but when i do it programaticly it gives me that error... here is my
            > > connection sub...
            > >
            > >
            > > Private dbconnectionstr ing As String = "workstatio n id=DELL5100;pac ket
            > > size=4096;integ rated security=SSPI;d ata source=BENE-SQL;persist security
            > > info=False;init ial catalog=ReschIn tranet"
            > > Public dbconnection As New SqlClient.SqlCo nnection(dbconn ectionstring)
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...