3

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 http://msdn.microsoft.com/en-us/library/cc707782.aspx 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?

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

1 Answer 1

1

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 ( 
  ADSI,  
  'SELECT displayName, telephoneNumber, mail, mobile, facsimileTelephoneNumber 
  FROM ''LDAP://bacon.lab''
  WHERE objectClass =  ''User'' 
  ') AS tblADSI
ORDER BY displayname
5
  • The problem isn't setting up a linked server but querying the LDAP which uses the Active Directory Helper Service Commented Jun 13, 2013 at 19:15
  • 1
    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
    Commented Jun 13, 2013 at 23:19
  • 1
    @user1207758: Those procedures have been removed in 2012. You will have to rewrite your code.
    – Jon Seigel
    Commented Jun 13, 2013 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
    Commented Aug 8, 2014 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
    Commented Aug 11, 2014 at 1:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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