Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In our current system, we query the LDAP using SQL Server 2008R2 but are moving to SQL Server 2012 where we have hit a snag. According to one of the discontinued features of SQL Server 2012 is the AD helper service.

Does anyone know of a way to query the AD from SQL Server 2012?

share|improve this question
You could e.g. use a web service and call it using SQL-CLR from your SQL Server code – marc_s Jun 13 '13 at 15:30
I would think this is possible using SQLCLR directly, but I haven't tried it. That's where I would start, though. – Jon Seigel Jun 13 '13 at 16:35

You should still be able to create a linked server to an LDAP database and query the LDAP database directly via the linked server.

There's information here on setting up the linked server.

To test I setup the linked server based on this post. Then I ran the following code and got back a recordset with various information in it (where bacon.lab is my AD domain).

SELECT * FROM OpenQuery ( 
  'SELECT displayName, telephoneNumber, mail, mobile, facsimileTelephoneNumber 
  FROM ''LDAP://bacon.lab''
  WHERE objectClass =  ''User'' 
  ') AS tblADSI
ORDER BY displayname
share|improve this answer
The problem isn't setting up a linked server but querying the LDAP which uses the Active Directory Helper Service – user1207758 Jun 13 '13 at 19:15
Setting up a linked server to AD on SQL 2012 I'm able to query active directory without issue via the linked server. The AD Helper service is used when SQL Server needs to create objects in AD, not when it needs to query AD. – mrdenny Jun 13 '13 at 23:19
@user1207758: Those procedures have been removed in 2012. You will have to rewrite your code. – Jon Seigel Jun 13 '13 at 23:22
@mrdenny, were you trying this with SQL Server 2012 and Windows Server 2012? I can't get it to work, even after following the instruction you provided. – datagod Aug 8 '14 at 16:49
When I wrote that sample code my lab would have been SQL 2012 on Windows 2012. Make sure that you change the domain name from bacon.lab to your domain name. – mrdenny Aug 11 '14 at 1:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.