troubleshooting Question

LDAP Assistance

Avatar of rbgCODE
rbgCODEFlag for United States of America asked on
Visual Basic Classic
3 Comments1 Solution718 ViewsLast Modified:
I am currently using this code, which does check and verify that a user is in AD, but what I would like to be able to do is also pull out their info, like a telephone number.  How can I do that?

Dim conLDAP As ADODB.Connection
Dim strSQL As String
Dim strLDAPConn As String
Dim rsUser As ADODB.Recordset
 gstrLDAPURL = "wServer": strUserName = "rBg": strPassword = "qwertY13$"
 Set conLDAP = New ADODB.Connection
 conLDAP.Provider = "ADSDSOOBject"
 strSQL = "Select * From 'LDAP://" & gstrLDAPURL & "' where objectClass='user'" & " and objectcategory='person'"
 conLDAP.Provider = "ADsDSOObject"
 conLDAP.Properties("User ID") = strUserName
 conLDAP.Properties("Password") = strPassword
 conLDAP.Properties("Encrypt Password") = True
 conLDAP.Open "DS Query", strUserName, strPassword
 Set rsUser = conLDAP.Execute(strSQL)
 Authenticate = False
 If Err.Number = 0 Then
  If Not (rsUser Is Nothing) Then
   If Not (rsUser.EOF And rsUser.BOF) Then
    Authenticate = True
    MsgBox rsUser.Fields("surname").Value
   End If
  End If
 ElseIf Err.Number = -2147217865 Then
  MsgBox "Error In LDAP settings" & vbCrLf & "Call Admin"
 End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros