I set up a linked server to the active directory using the following code:
EXEC master.dbo.sp_addlinkedserver @server = N'ADSI',
@srvproduct=N'Active Directory Services', @provider=N'ADsDSOObject',
I get a linked server. I can right click and test connection with an affirmative response. Then I click through to try and see the tables and I get the message in the attachment. When I try to run a query using this:
from openquery(ADSI, '
select title, sAMAccountName, displayName, userAccountControl
from ''LDAP://DC=ServerName.Domain,DC=COM'' ')
I get the following message:
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT sAMAccountname,givenname,s
WHERE objectCategory='person' AND objectClass='user'
ORDER BY CN" for execution against OLE DB provider "ADsDSOObject" for linked server "ADSI".
The "ServerName.Domain" is the name of the server on which active directory resides and the domain is the name of the network domain.
I added the network administrator as the remote login. I'm out of ideas as to why this is not working.