Results 1 to 7 of 7

Thread: SQL Server 2000/ AD/ Trused Connection problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    169

    SQL Server 2000/ AD/ Trused Connection problem

    Hi,
    I have a Windows Application, a Novell Network and a SQL Server 2000 on an Active Directory controlled server. My AD account has access to teh database. I want to login to the database using an Active Directory account, trusted security....but I can't.
    Sequence of Events:
    1. Login to Network using Novell account.
    2. Start Application and it displays login screen.
    3. Enter AD account details and press OK
    4. This verifies against Active Directory Account using the following code:

    VB Code:
    1. Public Function Login() As String
    2.       ' now create the directory entry to establish connection
    3.       Dim deDirEntry As New DirectoryEntry(Me.strDomain, Me.strUser, Me.strPass, Me.atAuthentType)
    4.       Try
    5.  
    6.         ' if user is verified then it will welcome then  
    7.         Try
    8.           Return deDirEntry.Username
    9.         Catch exp As Exception
    10.           Return ""
    11.         End Try
    12.       Finally
    13.         'deDirEntry.Dispose()
    14.       End Try
    15.     End Function 'Login

    This all works fine and returns the username if the credentials match
    5. Make database connection string (sUserName is the AD username):
    VB Code:
    1. Dim sConnstring As String = "User ID=" & sUserName & ";Initial Catalog=VendorSample;Data Source=MyServer...;Timeout=20;Trusted_Connection=True"
    6. I get the following error:
    Login failed for user '(null)'. Reason: Not associated witha trusted SQl Server connection.

    I'm not well up on how AD works etc. but does anybody have any idea how to get past this?

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Server 2000/ AD/ Trused Connection problem

    Is the SQL SERVER box setup for WINDOWS or SQL AUTHENTICATION.

    You should be able to see that in the PROPERTIES of the SERVER.

    Seems to me that you are trying to connect with SQL AUTHENTICATION (passing a username a password in the connection string) vs. WINDOWS AUTHENTICATION (where you do not give a username or password in the connection string).

    WINDOWS AUTHENTICATION is preferred - as the "credentials" to attach to the database are gathered from the username/pw the user entered to initially boot the workstation.

    Additional credentials can be loaded in the control panel - if using XP PRO - see the link in my signature if that has anything to do with your issue.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    169

    Re: SQL Server 2000/ AD/ Trused Connection problem

    Yes, the SQL Server is set up for Windows Authentication. Whether or not I pass a username, I get the same error message. The reason I was passing my AD username is that my windows and AD usernames are different

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Server 2000/ AD/ Trused Connection problem

    Quote Originally Posted by dec_obrien
    Yes, the SQL Server is set up for Windows Authentication. Whether or not I pass a username, I get the same error message. The reason I was passing my AD username is that my windows and AD usernames are different
    Then you cannot pass the username and password in the connection string - that is only for SQL authentication.

    Search the forum for SSPI or INTEGRATED SECURITY - you will find examples of connection strings for WINDOWS AUTHENICATION.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    169

    Re: SQL Server 2000/ AD/ Trused Connection problem

    But how do I get the Connection String to use the credentials of the Active Directory account?
    My Windows account does not have permissions on the database (this is the account I use to log initially boot my workstation). When I login to my app, I create an Active Directory directory entry using:
    Dim deDirEntry As New DirectoryEntry(Me.strDomain, Me.strUser, Me.strPass, Me.atAuthentType)
    where:
    strDomain is the domain; strUser is the username; strPass is the password; atAuthentType = false to not use SSL

    After this, it try to make the connection. If I simply use:
    "Initial Catalog=VendorSample;Data Source=MyServer...;Timeout=20;Integrated Security = SSPI" as the connection string, I get the error.

    This is driving me crazy and any help is greatly appreciated...

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Server 2000/ AD/ Trused Connection problem

    If you are using WINDOWS XP PROFESSIONAL then there is a link in my signature about getting around LOGIN USER NULL issues.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    169

    Re: SQL Server 2000/ AD/ Trused Connection problem

    I had a go at that on my PC and it didn't work. Did you mean to do that on the server?

Posting Permissions

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



Click Here to Expand Forum to Full Width