• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 646
  • Last Modified:

Can't open linked server to Active Directory

I created a linked server to Active Directory in SQL Server 2008.  I am getting the attached error.  Scripted linked server:

EXEC master.dbo.sp_addlinkedserver @server = N'ADSI', @srvproduct=N'Active Directory Service Interfaces', @provider=N'ADSDSOObject', @datasrc=N'adsdatasource'

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'ADSI',@useself=N'False',@locallogin=NULL,@rmtuser=N'my_username',@rmtpassword='########'

  • 3
1 Solution
Eric3141Author Commented:
I setup security to run under my userid whichy has network admin privileges.
Eric3141Author Commented:
Figured it out.  Query needs to be as below:

FROM OpenQuery(ADSI, 'SELECT title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn FROM ''LDAP://DC=sub-domain,DC=company,DC=com'' WHERE objectCategory=''user'' ')
Eric3141Author Commented:
If I work at MyStuff.com then the query would be:

SELECT * FROM OpenQuery(... FROM ''LDAP://DC=MyStuff,DC=COM''...

There is a "DC" to separate each part of the domain name.

If my domain = SomeAgency.ky.gov then the query would be:

SELECT * FROM OpenQuery(... FROM "LDAP://DC=SomeAgency,DC=KY,DC=gov''...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now