How to Query LDAP over SSL from SQL Server

Viewed 7203

Has anybody successfully queried LDAPS (LDAP over SSL/TLS) from SQL Server? How did you do it?

A client has asked us to set up our program on a network that uses LDAPS. I’ve used LDAP queries successfully at many other locations, but it’s not clear whether this will work with LDAPS, or what the syntax is. I would expect it to work, but not sure how to set it up.

As a test, we tried setting up LDAPS on our own network. We can connect using ldp.exe, but attempting to query it from SQL consistently fails with “Msg 7321, Level 16, State 2…”

  1. can a SQL query connect to LDAPS?
  2. Should I specify the port?
  3. Does the server certificate need to be imported into SQL Server, or elsewhere?
  4. Are there other extra setup steps needed beyond those normally needed for querying LDAP?

Here’s the query that normally works, which I’m trying to modify for LDAPS.

SELECT COUNT(*) FROM OPENROWSET('ADSDSOObject', 'adsdatasource'; 
'domain user here'; 'domain password here', 
    'SELECT SAMAccountName FROM 
''LDAP://192.168.0.105 
WHERE SAMAccountName = ''test.test'' and objectClass = ''user'' 
        ')
1 Answers
Related