Last post Jun 16, 2015 10:45 PM by ignatandrei
Jun 16, 2015 11:20 AM|Anon-A-Mouse|LINK
Hi, I hope I'm posting in the appropriate area.
I'm retrieving a list of groups from Active Directory and for some reason I can't determine the results are doubled. For example I'll get Group A, Group B, Group C, then a blank line and Group A, Group B, Group C again. The results are displayed in a dropdownlist.
I got the code for this from
here. I also tried the code from
here with the same results. No one has commented about the same thing happening to them so I'm stumped.
Here's my code:
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
'get groups from ad
Dim de As DirectoryEntry = New DirectoryEntry("LDAP://ou=app security groups,ou=firm wide,dc=na,dc=qb,dc=llp")
Dim usr As String
Dim oSearcher As DirectorySearcher = New DirectorySearcher(de)
oSearcher.Sort.PropertyName = "cn"
Dim oResults As SearchResultCollection
Dim oResult As SearchResult
oResults = oSearcher.FindAll
For Each oResult In oResults
usr = oResult.GetDirectoryEntry().Properties("cn").Value
'TextBox1.Text += usr
The dropdown is very simple:
<asp:DropDownList ID="ddlASGs" OnSelectedIndexChanged="ddlASGs_SelectedIndexChanged" AutoPostBack="true" CssClass="form-control dropdown" runat="server"></asp:DropDownList>
Jun 16, 2015 10:45 PM|ignatandrei|LINK