P
Peter Afonin
Hello,
I have a code that queries Active Directory and put logins and names into
the ArrayList. Then I need to bind this ArrayList to the DropdDownList,
making names as DataTextField and logins as DataValueFields.
I have no problem doing it, if I have only logins or only names, since
ArrayList always has one dimension. But I need them both. So the code looks
like this:
Sub Getallusers(ByVal selddl As DropDownList)
Try
Dim sAdsPath As String = "LDAP://seart01/dc=acdtraining,dc=com"
Dim de As New DirectoryEntry(sAdsPath, "Domain\user",
"password")
Dim ds1 As New DirectorySearcher(de)
ds1.Filter = "(objectCategory=person)"
ds1.Filter = "(objectClass=user)"
ds1.Filter = "(employeeType=ALT)"
'Dim colServers(100, 100) As String
Dim colServers As ArrayList
colServers = New ArrayList
Dim result As SearchResult
For Each result In ds1.FindAll()
colServers.Add(New String()
{result.Properties("displayName")(0),
result.Properties("samAccountName")(0)})
Next result
'colServers.Sort()
selddl.DataSource = colServers
??????????????????????????????????
selddl.DataBind()
de.Dispose()
Catch ex As Exception
Dim s As String = ex.Message
End Try
End Sub
The ArrayList is filling up OK, now each value contains two values - Name
(0) and Login(1). But how to extract them separately and make one a text
field and another - value field? Tried everything, but couldn't fugure out.
It's definitely possible, since each value has it's own index (0 or 1), but
I don't know how.
Alternatively, how would I use just an Array instead?
I would appreciate your help very much.
Thank you,
I have a code that queries Active Directory and put logins and names into
the ArrayList. Then I need to bind this ArrayList to the DropdDownList,
making names as DataTextField and logins as DataValueFields.
I have no problem doing it, if I have only logins or only names, since
ArrayList always has one dimension. But I need them both. So the code looks
like this:
Sub Getallusers(ByVal selddl As DropDownList)
Try
Dim sAdsPath As String = "LDAP://seart01/dc=acdtraining,dc=com"
Dim de As New DirectoryEntry(sAdsPath, "Domain\user",
"password")
Dim ds1 As New DirectorySearcher(de)
ds1.Filter = "(objectCategory=person)"
ds1.Filter = "(objectClass=user)"
ds1.Filter = "(employeeType=ALT)"
'Dim colServers(100, 100) As String
Dim colServers As ArrayList
colServers = New ArrayList
Dim result As SearchResult
For Each result In ds1.FindAll()
colServers.Add(New String()
{result.Properties("displayName")(0),
result.Properties("samAccountName")(0)})
Next result
'colServers.Sort()
selddl.DataSource = colServers
??????????????????????????????????
selddl.DataBind()
de.Dispose()
Catch ex As Exception
Dim s As String = ex.Message
End Try
End Sub
The ArrayList is filling up OK, now each value contains two values - Name
(0) and Login(1). But how to extract them separately and make one a text
field and another - value field? Tried everything, but couldn't fugure out.
It's definitely possible, since each value has it's own index (0 or 1), but
I don't know how.
Alternatively, how would I use just an Array instead?
I would appreciate your help very much.
Thank you,