Tags: below, database, error, ldap, level, microsoft, msg, mysql, oracle, query, run, server, sql, tsql, via

SQL 2005 LDAP Query Error: Msg 7321, Level 16

On Database » Microsoft SQL Server

3,554 words with 5 Comments; publish: Sun, 23 Dec 2007 02:27:00 GMT; (25062.99, « »)

Hello I am trying to run a query via tsql against ad. Below is the error I am getting. I have read the http://msdn2.microsoft.com/en-US/library/ms190803.aspx and changed the domain but still having issues. Any help would be appreciated.

EXEC sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces',

'ADSDSOObject', 'adsdatasource'

GO

SELECT *

FROM OPENQUERY( ADSI,

'SELECT Name, SN, ST

FROM ''LDAP://ADSISrv/ OU=Users,DC=XXXXX,DC=LOCAL''

WHERE objectCategory = ''Person'' AND

objectClass = ''user''')

Msg 7321, Level 16, State 2, Line 1

An error occurred while preparing the query "SELECT Name, SN, ST

FROM 'LDAP://ADSISrv/ OU=Users,DC=XXXXX,DC=LOCAL'

WHERE objectCategory = 'Person' AND

objectClass = 'user'" for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI".

All Comments

Leave a comment...

  • 5 Comments
    • Check if the linked server (ADSI) allow remote accessing.
      #1; Thu, 30 Aug 2007 14:16:00 GMT
    • I got it to work on the local database server. It didn't seem to like the OU. Once I removed it the query completed. However I still get the message if I try and run the view from a remote computer using Mgmt Studio is there something I have to setup on the clients?

      SELECT * FROM vcnet.dbo.viewADContacts--gives errors from workstations but not if run from the server itself

      Server: Msg 7321, Level 16, State 2, Line 1

      An error occurred while preparing the query "SELECT sAMAccountname,givenname,sn,displayname,useraccountcontrol,CN, manager, mobile , mail, objectCategory,

      department,

      telephoneNumber,

      facsimileTelephoneNumber

      FROM 'LDAP://DC=XXXXX,DC=local'

      WHERE objectCategory='person' AND objectClass='user'" for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI".

      #2; Thu, 30 Aug 2007 14:17:00 GMT
    • Did you ever get a resolution to this? I am now having the same issue - query runs fine on the local SQL2k5 server but not on a remote server running Visual Dev.
      #3; Thu, 30 Aug 2007 14:18:00 GMT
    • I'm having the same issue - query runs in management studio, but not elsewhere. Any idea why?
      #4; Thu, 30 Aug 2007 14:19:00 GMT
    • The domain name is required in the Security settings for the remote login - I should have known that. So in the Security settings I selected : password.

      #5; Thu, 30 Aug 2007 14:20:00 GMT