CharlieT302
Instructor
Hi Folks,
I have the following command code that extracts the first and last names of all users in the Active Directory. It displays the names in the Immediate Window. However, I need to pull them into a combo box as the record source.
I am thinking that I need a Select statement and probably not a Debug.Print command. I am unsure how to set it up. Any ideas?
Current Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=ad,dc=Oggwin,dc=org>;(objectcategory=user);sn,givenname;subtree"
Set objRecordset = objCommand.Execute
While Not objRecordset.EOF
Debug.Print objRecordset.Fields("givenname") & "," & objRecordset.Fields("sn")
objRecordset.MoveNext
Wend
objConnection.Close
I have the following command code that extracts the first and last names of all users in the Active Directory. It displays the names in the Immediate Window. However, I need to pull them into a combo box as the record source.
I am thinking that I need a Select statement and probably not a Debug.Print command. I am unsure how to set it up. Any ideas?
Current Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<LDAP://dc=ad,dc=Oggwin,dc=org>;(objectcategory=user);sn,givenname;subtree"
Set objRecordset = objCommand.Execute
While Not objRecordset.EOF
Debug.Print objRecordset.Fields("givenname") & "," & objRecordset.Fields("sn")
objRecordset.MoveNext
Wend
objConnection.Close