ldap - Looping through each item in a ListBox control with VB.NET -


I wrote down the program to see a LDAP user and return a property. The way I need to work, is as follows: I will first load the list of user IDs in ListBox1 , then when I click on a button, a property (such as DisplayName) To ListBox2 . Now I want to click on an item in ListBox1 and then click on the button and it works, but I want to loop it through every ID in ListBox1 And write properties for them without having to click on each of my user IDs for ListBox2 How can I add it to each loop?

  New directory in the form of Dim D: Central ("LDAP: //test.com/DC=test,DC=com") Dim LdapFilter as String = "(SAMAccountName =" & ListBox1 .txt & amp; ")" Search Researcher as a New Searcher (D, LDAPFilter) search result as search result = searcher FundOn () ListBox2.Items.Add (Results Properties ("displayName") (0) .ostring ())  

Update

I tried to use the ListView to display two columns, as suggested, this is not working, though. It just adds the ListView column:

  View the dim item as a listEvent = List view 1. item. Add ("user name") dim item1 as list View Event = ListView1.Items.Add ("Title") as the string in the list for each 1. It is dim as a new directory ("LDAP: //test.com/DC=test,DC=com") as a slow LdapFilter string = "(sAMAccountName =" & amp; i & Amp; ") as the explorer Find results in the form of a new finder explorer (D, LDAPFilter) search result = finder.fundon () items. SubItems.Add (Results Properties ("sAMAccountName") (0) .ostring ()) Item1.SubItems (Results Properties ("title") (0) .ostring ()) Dynamic Entry Directory Entry = New DirectoryInterity (Results .path) If the results ("DisplayName") is nothing again then start the error again Next End  

You should not really use ListBox1.Text property is rather confusing in this case, you can list all ListBox1.Items Want to loop through strings (supposedly they are actually string). For example:

  for each As a string in ListBox1. Currently the new directory entry ("LDAP: //test.com/DC=test,DC=com") is in the form of a slow LdapFilter string = "(SAMAccountName =" & amp; I & amp; ")" Finder as a search result for new directory finder (D, LDAP filter), search = searcher FundOn () ListBox2.Items.Add (Results Properties ("displayName") (0) .ostring ()) Next  

Or, if ListBox1 actually If you do not have the strings, then you can get them as Object and call the toString method on each one, such as:

 < Code> as the object in ListBox1 for each. Currently the entry given as the new directory ("LDAP: // test .com / DC = test, DC = com") as the LDAPFilter in the form of a string = "(sAMAccountName =" & i.ToString () & New directory finder (D, LdapFilter) results as search result = searcher. FindOne () PropertiesBox2.Items.Add (Results Properties ("displayName") (0) .ostring (. )) Next  

As I used to give me two different ListBox in the comments below instead of using the controls, two It would be better to use the ListView control with columns. For example, if you had a ListView1 control with three columns (the heading "ID", "username", and "title"), then you can add items like this: < Get the list of 'id =' getAllLdapUserIds () 'ID of the IEnumerable (string) =' id 'as the slow userIds, which means that you currently have the new directory as UserIID low disk in the string for each I Entry ("LDAP: //test.com / DC = test, DC = com") Dim LdapFilter form In String = "(SAMActonName =" and ")" Dot Detector (D, LDAPFilter) Search Result = Searcher as the searcher explorer FundOn () Dim Item ListViewItem = ListView1.Items.Add (i) Item SubItems.Add (Results Properties ("sAMAccountName") (0) .ToString ()) item.SubItems.Add (Results Properties ("Title" ) (0) .ostring ()) Next


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -