Something weried happening when i try and return 4 AD properties to a listview box, here is my code:
Expand|Select|Wrap|Line Numbers
- Dim li As ListViewItem
- Dim dirEntry As DirectoryEntry = New DirectoryEntry("LDAP://172.16.0.3/OU=Staff,OU=Users,OU=Accounts,OU=Network,DC=X,DC=local")
- dirEntry.Username = "x"
- dirEntry.Password = "x"
- Dim search As DirectorySearcher = New DirectorySearcher(dirEntry)
- search.Filter = "(&(objectClass=User)(objectCategory=person))"
- Dim res As SearchResultCollection = search.FindAll()
- For Each ItemRes As SearchResult In res
- li = Me.ListView1.Items.Add(ItemRes.Properties("displayname")(0).ToString())
- li.SubItems.Add(ItemRes.Properties("department")(0).ToString())
- li.SubItems.Add(ItemRes.Properties("homePhone")(0).ToString())
- li.SubItems.Add(ItemRes.Properties("mail")(0).ToString())
- Next
If i return the items to messageboxes they return fine.
Have i coded the subitems right on the listview?
Thanks,
James.