Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Question Unanswered: login failed for user -- why?

    I have an ASP.NET intranet app in c# accessing a SQL 7 database that used to work before we move to a new Windows 2003 server. Don't know if win2k3 server has anything to do with it.

    I run the website for now on my machine, IIS config for the site is no anonymous access, Integrated Windows security only, but it doesn't seem to matter what I use.

    We had to change from using a common user id/pw to Integrated security. I run the app in VS2003 studio, and try to connect with this code and string:

    WebConfig:
    <add key="connectionString" value="Data Source=chchtdev02;Initial Catalog=InsourceMaster;Integrated Security=SSPI" />

    cs file:
    SqlConnection myConn = new SqlConnection(connStr);
    myConn.Open();

    The group 'Development Global' of which I am a member has been added to the System Administrator role on the SQL 7 installation on the new server.

    I've even added my own network logon alone and tried to use the string
    <add key="connectionString" value="Data Source=chchtdev02;Initial Catalog=InsourceMaster;user id=myusername;password=mypassword />

    causing basically the same error. Both are included below.

    Anyone have any ideas what I'm missing here?



    Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.

    Source Error:


    Line 229: int i;
    Line 230: SqlConnection myConn = new SqlConnection(connStr);
    Line 231: myConn.Open();
    Line 232: SqlCommand cmd = new SqlCommand();
    Line 233: cmd.Connection = myConn;


    Source File: c:\inetpub\wwwroot\xmlinsourceedit\xmlinsourceedit .aspx.cs Line: 231

    Stack Trace:


    [SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.]
    System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction)
    System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction)
    System.Data.SqlClient.SqlConnection.Open()
    XMLInsourceEdit.XMLInsourceEdit.FillDropDownsFromS ql(String gStatecode, String gBookcode, String gTypecode) in c:\inetpub\wwwroot\xmlinsourceedit\xmlinsourceedit .aspx.cs:231
    XMLInsourceEdit.XMLInsourceEdit.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\xmlinsourceedit\xmlinsourceedit .aspx.cs:151
    System.Web.UI.Control.OnLoad(EventArgs e)
    System.Web.UI.Control.LoadRecursive()
    System.Web.UI.Page.ProcessRequestMain()



    Login failed for user 'myusername'.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'myusername'.

    Source Error:


    Line 229: int i;
    Line 230: SqlConnection myConn = new SqlConnection(connStr);
    Line 231: myConn.Open();
    Line 232: SqlCommand cmd = new SqlCommand();
    Line 233: cmd.Connection = myConn;


    Source File: c:\inetpub\wwwroot\xmlinsourceedit\xmlinsourceedit .aspx.cs Line: 231

    Stack Trace:


    [SqlException: Login failed for user 'myusername'.]
    System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction)
    System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction)
    System.Data.SqlClient.SqlConnection.Open()
    XMLInsourceEdit.XMLInsourceEdit.FillDropDownsFromS ql(String gStatecode, String gBookcode, String gTypecode) in c:\inetpub\wwwroot\xmlinsourceedit\xmlinsourceedit .aspx.cs:231
    XMLInsourceEdit.XMLInsourceEdit.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\xmlinsourceedit\xmlinsourceedit .aspx.cs:151
    System.Web.UI.Control.OnLoad(EventArgs e)
    System.Web.UI.Control.LoadRecursive()
    System.Web.UI.Page.ProcessRequestMain()

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    I'm still taking my first tentative steps with ASP.NET, so I may be off base here; still, I'll take a stab because I think I ran into something similar recently.

    ASP.NET runs under the context of the (localmachine)\ASPNET user account. You will need to add this user to the SQL Logins (sp_grantaccess)in order to use integrated security. If you're SQL server is not local, then you will need to add (localmachine)\ASPNET into a Domain Group and add the Domain Group into SQL Logins.

    I know that you indicated that you were running the website with windows authentication. I did the same thing, but for some reason it would not accept my credentials (that was another issue that took some time to resolve).

    Also, check out www.connectionstrings.com. They had some good information on connecting with the ASP.NET SQLClient object. I think I had to type the keywords that they gave exactly as given (case sensitive) in order to get anywhere. I realize that doesn't sound right, but it is what worked for me finally.

    That's part of the reason I have been so hesitant with ASP.NET; it seems in so many respect to be foreign to me. Sigh, I guess I'm getting too old to learn new tricks.

    Good Luck,

    hmscott
    Have you hugged your backup today?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •