URGENTT: Login failed for user '(null)'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JustRun
    New Member
    • Mar 2008
    • 127

    URGENTT: Login failed for user '(null)'

    Hi ,

    I use .NET 2.xx for developing an intranet site, The IIS (my application) on Server1 (Domain controller) the SQl server 2000 on Server2.
    and both servers running through windows 2003.

    I did the following steps,

    1- Create Domain account on the Domain controller (Server1\ASPNET )
    2- Made new login on the SQL, and created new user on the database I want to access, then I gave that user permissions to access my stored procedure and views.
    User Name: Server1\ASPNET
    Login Name: Server1\ASPNET
    3- enabled the Network Service in the Temporary ASP.NET Files

    Actually I did many other things that i can't remember just to make that application work
    I still have that stubid error:
    Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection :(.

    I'm wondering Should I replace ASPNET with NETWORKSERVICE cause it windows 2003 !!!

    Please answer me I've spend 4 days trying to publish this site with no use !!
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    May actually be your connection string. This article may help:
    SQL SERVER - Fix : Error: 18452
    Originally posted by JustRun
    Hi ,

    I use .NET 2.xx for developing an intranet site, The IIS (my application) on Server1 (Domain controller) the SQl server 2000 on Server2.
    and both servers running through windows 2003.

    I did the following steps,

    1- Create Domain account on the Domain controller (Server1\ASPNET )
    2- Made new login on the SQL, and created new user on the database I want to access, then I gave that user permissions to access my stored procedure and views.
    User Name: Server1\ASPNET
    Login Name: Server1\ASPNET
    3- enabled the Network Service in the Temporary ASP.NET Files

    Actually I did many other things that i can't remember just to make that application work
    I still have that stubid error:
    Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection :(.

    I'm wondering Should I replace ASPNET with NETWORKSERVICE cause it windows 2003 !!!

    Please answer me I've spend 4 days trying to publish this site with no use !!

    Comment

    • JustRun
      New Member
      • Mar 2008
      • 127

      #3
      Hi kenobewan,

      I don't think its the connection string, cause it worked well when I tried to work with the visual studio and it worked well when I tried to connect remotely to the Sql Server on Server2.

      I serched a lotttttttt in google with no use!!
      I'm pulling my hair out. :_(

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Originally posted by JustRun
        Hi kenobewan,

        I don't think its the connection string, cause it worked well when I tried to work with the visual studio and it worked well when I tried to connect remotely to the Sql Server on Server2.

        I serched a lotttttttt in google with no use!!
        I'm pulling my hair out. :_(
        If you are running an application pool that uses network service this may resolve, otherwise not. Publish the full error message, include error and line number if available. Are you running under https? What is your connection string and where does it reside?

        Comment

        • JustRun
          New Member
          • Mar 2008
          • 127

          #5
          I have tried to access the database server remotely from the aspnet account [server2\aspnet] and registered the database server on the sql server on this account [server2\aspnet]. I could successfully access my database. THANK GOD

          BUT, when I tried to run it again [http:\\myntrane tsite.com\defau lt.aspx] it brings me this one error line says also the same error if I tried to access any html or txt page, that means its not an asp.net problem :_(

          Title: 404 Not Found
          Body: Not Found
          The requested URL /default.aspx was not found on this server.

          I think that it might be from the proxy server.


          Originally posted by kenobewan
          If you are running an application pool that uses network service this may resolve, otherwise not. Publish the full error message, include error and line number if available. Are you running under https? What is your connection string and where does it reside?

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            Originally posted by JustRun
            BUT, when I tried to run it again [http:\\myntrane tsite.com\defau lt.aspx] it brings me this one error line says also the same error if I tried to access any html or txt page, that means its not an asp.net problem :_(

            Title: 404 Not Found
            Body: Not Found
            The requested URL /default.aspx was not found on this server.
            Confirm that you are using http://myntranetsite.c om/default.aspx and not http:\\myntrane tsite.com\defau lt.aspx?

            Comment

            • JustRun
              New Member
              • Mar 2008
              • 127

              #7
              I dont believe that no one can help me in this damn error,

              Please, I'm gonne lose my job offer If I didnt fix this. I have spent about 7 days searching with no use !!

              1. Create a Domain Account with priveleges similar NETWORKSERVICE (windows server 2003).

              2. Grant this Domain Account (DomainName/NETWORKSERVICE ) access in the SQL Server Database for the necessary databases (created a new login for this user and gave it the privillage creator, read, write)

              3. <identity impersonate="tr ue" userName="Domai nName\UserName" password="passw ord" />

              NOTE: This code created an error while I put it in my web.config

              The second method is to simply set identity impersonate to true and assign the username and password in the IIS.

              To do that, do the following steps

              1. Type inetmgr from your command prompt and give enter.

              2. This would open the IIS Control Panel.

              3. Expand the appropriate nodes and select the Virtual Directory of your application.

              4. Right Click and select Properties.

              5. Switch to the Directory Security Tab.

              6. Under Anonymous access and authentication control click Edit

              7. Check the Enable Anonymous access in case you want people to access the application without logging in with Windows Logon Screen.

              8. Uncheck the Allow IIS to control password and enter the DomainName/UserName and Password in the respective boxes. Usually IIS uses IUSER_MACHINENA ME credentials for Anonymous access.

              9. Uncheck if any other authentication mode is checked

              I did the previous step exactly like that. and the error still come.
              I remind you again we have a proxy server with one firwall
              Please find me a solution

              Comment

              • kenobewan
                Recognized Expert Specialist
                • Dec 2006
                • 4871

                #8
                Here is another article that may help:
                You may receive the error "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection" - Part I

                Please read the posting guidelines. Multiposting is against site rules. While you are obviously stressed, your job is not our responsibility. Suggest you undertake training or buy a book.

                MODERATOR

                Comment

                • JustRun
                  New Member
                  • Mar 2008
                  • 127

                  #9
                  Thanks mr. MODERATOR!

                  By the way I know the my job is not your responsibility and I didn't say that.
                  Also I said that i followed that site instructions before "Part 2" cause part 2 is my case. but I'll fix this error soon.

                  Newbie

                  Originally posted by kenobewan
                  Here is another article that may help:
                  You may receive the error "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection" - Part I

                  Please read the posting guidelines. Multiposting is against site rules. While you are obviously stressed, your job is not our responsibility. Suggest you undertake training or buy a book.

                  MODERATOR

                  Comment

                  • balabaster
                    Recognized Expert Contributor
                    • Mar 2007
                    • 798

                    #10
                    Hey, I can't guarantee that this is a solution to your issue, but I've come across this error before in SQL Server 2005 and in my case, it didn't appear to be anything to do with IIS. What I found is that it was in my SQL Server settings - the user is not correctly associated with the database and consequently can't log in.

                    How I cured it:
                    • In SQL Server expand your database out to
                      Databases\[Database]\Security\Users
                    • Right click the user in question and delete it.
                    • Now - in the server there is also a security object.
                    • Expand Security\Logins
                    • You will also see the user in this folder.
                    • Edit it by double clicking on the user.
                    • In the left pane that appears there is a selection called User Mapping - select it.
                    • On the right hand side you now have two panes. In the top one make sure your database is checked (and selected).
                    • In the bottom one, make sure that at least db_reader is selected...if you need this user to be able to write to the database, make sure that db_writer is also selected. If this user is the database owner (which given that it's the ASPNET account, I suspect not) then make sure that db_owner is selected.
                    • Click OK
                    This process will recreate the user at the database level that you deleted and it should now be associated correctly, therefore alleviating the issue.

                    There is a way to actually fix/associate the user you deleted rather than deleting and recreating it, but I found it far quicker and simpler to use the method I describe - which once you've done it a couple of times will only take you a few seconds at most.

                    The issue occurs when you detach/re-attach databases to your database server - it doesn't associate the database level user with the database server level user and consequently you have to either manually link the two, or just delete the one at the database level and re-associate the system level user with the database.

                    I hope this helps...and that you manage to keep your job ;o)

                    Comment

                    • JustRun
                      New Member
                      • Mar 2008
                      • 127

                      #11
                      Thank you Balabaster,

                      thanks for everyone, I've fixed it today. and here is the solution:

                      the old connection string one that didn't work:
                      connectionStrin g="Data Source=database server IP;Initial Catalog=databas e name;Integrated Security =True;User ID=sa;Password= password"

                      the correct one:
                      connectionStrin g="Data Source=database server IP;Initial Catalog=databas e name;Persist Security Info=True;User ID=sa;Password= password"

                      Thank God, kenobewan and Balabaster

                      Originally posted by balabaster
                      Hey, I can't guarantee that this is a solution to your issue, but I've come across this error before in SQL Server 2005 and in my case, it didn't appear to be anything to do with IIS. What I found is that it was in my SQL Server settings - the user is not correctly associated with the database and consequently can't log in.

                      How I cured it:
                      • In SQL Server expand your database out to
                        Databases\[Database]\Security\Users
                      • Right click the user in question and delete it.
                      • Now - in the server there is also a security object.
                      • Expand Security\Logins
                      • You will also see the user in this folder.
                      • Edit it by double clicking on the user.
                      • In the left pane that appears there is a selection called User Mapping - select it.
                      • On the right hand side you now have two panes. In the top one make sure your database is checked (and selected).
                      • In the bottom one, make sure that at least db_reader is selected...if you need this user to be able to write to the database, make sure that db_writer is also selected. If this user is the database owner (which given that it's the ASPNET account, I suspect not) then make sure that db_owner is selected.
                      • Click OK
                      This process will recreate the user at the database level that you deleted and it should now be associated correctly, therefore alleviating the issue.

                      There is a way to actually fix/associate the user you deleted rather than deleting and recreating it, but I found it far quicker and simpler to use the method I describe - which once you've done it a couple of times will only take you a few seconds at most.

                      The issue occurs when you detach/re-attach databases to your database server - it doesn't associate the database level user with the database server level user and consequently you have to either manually link the two, or just delete the one at the database level and re-associate the system level user with the database.

                      I hope this helps...and that you manage to keep your job ;o)

                      Comment

                      Working...