Since my original post, I have made some progress. I have written the following VBA code:
****************************************
Private Const RootPath As String = "LDAP://dc=MyOrganizationDomainName,dc=com"
Private Sub cmdGetADInfo_Click()
Const ADS_SCOPE_SUBTREE = 2
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
Dim i As Integer
conn.Provider = "ADsDSOObject"
conn.Open "Active Directory Provider"
Set cmd.ActiveConnection = conn
Me.txtUserName.SetFocus
cmd.Properties("Page Size") = 1000
cmd.Properties("Searchscope") = ADS_SCOPE_SUBTREE
cmd.CommandText = "SELECT * FROM '" & RootPath & _
"' WHERE objectCategory='user' And sAMAccountName = '" & Me.txtUserName.Text & "'"
Set rs = cmd.Execute
rs.MoveFirst
i = 0
Do While Not rs.EOF
MsgBox "The field name is: " & rs.Fields(i).Name
MsgBox "The field value is: " & rs.Fields(i).Value
i = i + 1
rs.MoveNext
Loop
rs.Close
End Sub
****************************************
What this gives me is a single record with a single field from AD given a valid username from the txtUserName text box. The record set I get has a field name of "ADsPath" and a field value of "LDAP://CN=ValidUserName,OU=ValidContainerName,DC=MyOrganizationDomainName,DC=com". I need to get to the individual fields in AD that contain the user's mailing address fields, phone number fields, manager field, department field, etc. Any ideas?
Thanks,
T-Tops