Unbind from the directory server.
Disconnect
' Find first names of all the Smiths.
Set pLDAP = CreateObject("LDAPClient.3")
Call pLDAP.Connect("ldapserver")
Set pAttributeNames = CreateObject("LDAPClient.StringCollection")
Call pAttributeNames.Add("givenName")
' Find all the Johns and all the Smiths
Set pEntries = pLDAP.Search("o=airius.com", "(|(givenName=John)(sn=Smith))", , pAttributeNames)
For Each pEntry In pEntries
MsgBox pEntry.Attributes("givenName").Values(0).Value
Next
Call pLDAP.Disconnect
' Try finding all Johns and all Smiths again
Set pEntries2 = pLDAP.Search("o=airius.com", "(|(givenName=John)(sn=Smith))", , pAttributeNames)
' pEntries2 will be an empty LDAPEntryCollection since Search was called after Disconnect
For Each pEntry In pEntries2
MsgBox pEntry.Attributes("givenName").Values(0).Value
Next