Only the data of ADsPath can be outputted.
Can reference of LDAP search only the data
of ADsPath?
Please let me know the place in which it has made
a mistake by the program.
Thank you for your consideration.
English is not the lower part.
Environment
Windows 2000 Professional SP2
Microsoft Visual Basic 6.0 SP5
ADO ADSI
Microsoft Active Directory Server
Code
Private Sub Command1_Click()
Dim oConnection As ADODB.Connection
Dim oCmd As ADODB.Command
Dim oRecordSet As ADODB.Recordset
Dim oField As ADODB.Field
Dim strADOQuery As String
Dim strAttributes As String
Dim strFilter As String
strAttributes = "ADsPath,name,distinguishedName,cn,givenName,sn"
strFilter = Trim(InputBox("Please input a filter to find users. Entering
nothing will return all users." + vbLf + vbLf + "Example : (sn=Smith) finds
all users with the last name Smith", "Enter a filter"))
Set oConnection = New ADODB.Connection
Set oCmd = New ADODB.Command
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
Set oCmd.ActiveConnection = oConnection
strADOQuery =
"<LDAP://xxx.yyy.co.jp>;(&(objectCategory=person)(objectClass=user)" +
strFilter + ");" + strAttributes + ";subtree"
oCmd.CommandText = strADOQuery
oCmd.Properties("Page Size") = 1000
Set oRecordSet = oCmd.Execute
While Not oRecordSet.EOF
For Each oField In oRecordSet.Fields
List1.AddItem oField.Name + " : " + oField.Value
Next
oRecordSet.MoveNext
Wend
oRecordSet.Close
oConnection.Close
Set oField = Nothing
Set oRecordSet = Nothing
Set oCmd = Nothing
Set oConnection = Nothing
End Sub
by Hiroki Funahashi