title: MS Access 2010 using ldap authentication
body: <p>I am trying to do ldap authentication in ms access 2010 using username and password. I cannot seem to figure this out and have tried different codes online but none seem to work. Can anyone help?</p>
  
  <p>The following is what i have taken from <a href="http://www.utteraccess.com/forum/LDAP-Authentication-t1844479.html" rel="nofollow">here</a></p>
  
  <pre><code>Function CheckUser(username As String, passwd As String, Level As Integer) As Boolean
  
      On Error GoTo LDAP_Error
  
      username = "sharifu"
      passwd = "xxx"
  
      Const ADS_SCOPE_SUBTREE = 2
  
      Dim LDAPPath As String
      LDAPPath = "LDAP://172.16.0.12/OU=Sites;DC=domain;DC=com"
  
      Dim conn As ADODB.Connection
      Dim cmd As ADODB.Command
      Dim rs As ADODB.Recordset
  
      Set conn = New ADODB.Connection
      Set cmd = New ADODB.Command
      conn.Provider = "ADsDSOObject"
  
      conn.Properties("User ID") = "domain\" &amp; username
      conn.Properties("Password") = "" &amp; passwd
      conn.Properties("Encrypt Password") = True
      'conn.Properties("ADSI Flag") = 3
  
      conn.Open "Active Directory Provider"
      Set cmd.ActiveConnection = conn
  
      cmd.Properties("Page Size") = 1000
      cmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  
  
      cmd.CommandText = _
      "SELECT Name FROM '" &amp; LDAPPath &amp; "' WHERE " &amp; "objectCategory='user'"
  
      Set rs = cmd.Execute
  
      rs.Close
      conn.Close
  
      CheckUser = True
      Exit Function
  
  LDAP_Error:
  
      If Err.Number = -2147217911 Then
  
      MsgBox "Incorrect PeopleSoftID or Password!", vbExclamation, "HILDA"
  
      Else
  
      MsgBox "Error : " &amp; Err.Description &amp; " " &amp; Err.Number, vbExclamation, "HILDA"
  
      End If
      CheckUser = False
  
      conn.Close
  
  
  End Function
  </code></pre>
  
  <p>Error I receive is </p>
  
  <p>"Error: The server is not operational.
  -2147217865"</p>
  
  <p>Changed to ip address get following error now</p>
  
  <p><code>Method 'ActiveConnection' of object '_Command' failed</code> but it might be coming from elsewhere in my code. how would i check if ldap was success?</p>