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

  • Hi

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

    My Environment Configuration.

    1. Client Machine : Windows 2003 Server X64 bit Edition OS in this machine My VC++ application is running.

    2. Server Machine : Windows 2003 Server 32 bit Editon OS in this machine SqlServer2000 SP4 is running.

    When i connect my client VC++ application to SqlServer2000 i am getting this error "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection".

    I can able to create DSN(Client Machine) to SqlServer 2000 (Server machine) its created sucessfully and test connection also ok.

    Can u tell any body what is problem in my setup and how to resolve this issue

    Thanks in Advance.

    Regards

    Sudhan

  • I usually get this error when I'm connecting to SQL Server using Windows Authentication. When you make your DSN are you using windows authentication, or SQL Server authentication? Also, check out http://www.connectionstrings.com to make sure your connection string is formatted properly.

  • Looks like you're trying to use SQL authentication to a server that's configured for windows authentication only.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks For your inforamtion.

    Already In my Sql Server i am using Mixed Mode(Sql and Windows Authentication) only. Still i am getting same error.

    Please provide solution for me.

    Thanks

    Sudhan

  • Hi Gail Shaw

    My SQLServer 2000 machine registry value for login mode =2

    HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServer\MSSQLServer\LoginMode = 2

    Then its SQL and Windows Authentication only, is it right?

    But Same setup when i try to connect another machine with SqlServer 2005 there no issues.

    I am waiting for your valuable solution for me.

    Regards

    Sudhan

  • Can you post the connection string that you're using please?

    Dunno about the login mde. Take a look at the properties of the server in enterprise manager and see what its set to.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If the words "Integrated Security" appear in your connection string you've got the wrong connection string for your setup.

    Try something along this line:

    connectionString="Data Source=dbservername;Initial Catalog=databasename;UID=sqlloginname;PWD=sqlpassword"

  • Here i have mention my connection string

    i am using ADO db connection with DSN name,username, password

    _RecordsetPtr pRs;

    bstrSQLConnect += (LPCTSTR)m_DataSourceName;

    bstrSQLConnect += (LPCTSTR)m_UserName;

    bstrSQLConnect += (LPCTSTR)m_Password;

    pRs->Open(bstrSQL, bstrSQLConnect, adOpenDynamic, adLockReadOnly,adCmdText);

    Regards

    Sudhan

  • Could we see the entire connection string please?

    Just before you do the pRs->Open, print the connections string to the debug (or similar) and post the result (remving the password of course)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You will get this error if you are using Windows authentication but the client machine is not logging into the domain (or AD) that the server is on. I have this problem linking over VPN to some client sites - the solution for me (XP client to various different versions of Windows servers running mainly SQL 2K) was to run the windows "Key Manager (probably available somewhere in control panel - but as MS like to move and rename these things all the time I have a shortcut to:

    C:\WINDOWS\system32\rundll32.exe keymgr.dll, KRShowKeyMgr

    Then you can add a new server to the cached credentials - e.g. click Add then

    Server box: name of server e.g. MYSQLSERVER

    User name box: domain and name of valid user on MYSQLSERVER e.g. MYDOMAIN\username

    Password ... password for that user in that domain

    OK that then try connecting and Windows should use those credentials rather than the credentials you used to log into local machine

  • Not sure if this applies to your situation, but...

    We have an asp.net application on our IIS box which hits a SQL server 2000 database on another box. We are implementing integrated authentication and got the same error message. (Also, we have Active Directory.) On the IIS box the web application opened fine, but from the client we got the "Login failed for user '(null)'..." message. Now, from IIS manager, if we set the security to Basic Authentication it worked. However, Basic is not secure, so we kept working at it until we found these links below.

    If you have the "double-hop" problem (client to IIS box then IIS box to SQL server box) check out this Microsoft Technet Support Webcast

    http://support.microsoft.com/kb/887682

    There is a lot to configure: the client, the IIS box, the SQL server box, Active Directory settings, and SPN's...our problem was not setting the spn's correctly.

    Note: On page 11 of the PowerPoint presentation, the first two SPN examples are wrong (don't put the port), they should read:

    HTTP/iisserver

    HTTP/iisserver.mydomain.com

    If you are having kerberos problems, here is another Microsoft link to check out...

    Troubleshooting Kerberos Delegation: http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/security/tkerbdel.mspx

  • Thank you Mr. Horsley, for this excellent solution.

  • why not install Client Network Utility on your machine?!?

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply