[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

query active directory in sql 2008

this is the query that i use
SELECT *
  FROM OPENQUERY(ADSI,
       'SELECT  mail, displayName, sAMAccountName, givenName, sn, cn,  userAccountControl
          FROM ''LDAP://yourdomain.com''
          where objectClass = ''User'' order by cn')

and this works fine when i am on the sql server. but if i am on developer machine and use studio management, it gives me this error
An error occurred while preparing the query "SELECT  mail, displayName, sAMAccountName, givenName, sn, cn,  userAccountControl
          FROM 'LDAP://yourdomain.com'
          where objectClass = 'User' order by cn" for execution against OLE DB provider "ADsDSOObject" for linked server "ADSI".


any help is really appreciate
0
StewSupport
Asked:
StewSupport
1 Solution
 
Evan CutlerCommented:
Hi...
Give this a shot.
http://sql.dzone.com/news/querying-active-directory-thro

it could be a link error in your sql server, or just a querying issue.

Cheers.
0
 
StewSupportAuthor Commented:
what i did to fix my problem is that i went into security in the create new link server wizard and click on the radio button that says use this login and specify the login. thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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