Vayse,
Imports System.DirectoryServices
Private Sub LoadAllUsers()
'This will list all users in the Domain
Dim strDirEntryPath As String = "WinNT://" & MyDomain & "/" &
MyServer & "/" & "Domain Users" & ",group"
Dim group As New DirectoryEntry(strDirEntryPath)
Dim users As Object
users = group.Invoke("members")
Dim user1 As Object
'Datatable just used for sorting
Dim DT As New DataTable
Dim DC As New DataColumn("users")
DT.Columns.Add(DC)
Dim r1 As DataRow
Dim StrName As String
'Add each user to the data table
For Each user1 In CType(users, IEnumerable)
r1 = DT.NewRow
Dim userEntry As New
System.DirectoryServices.DirectoryEntry(user1)
r1.Item(0) = userEntry.Name
DT.Rows.Add(r1)
Next
'Use Data View to Sort Articles
Dim DV As New DataView(DT)
DV.Sort = "users asc"
Dim intCount As Integer = 0
For intCount = 0 To DV.Count - 1
Me.cboUsers.Items.Add(DV.Item(intCount).Row.Item(0))
Next
End Sub

Signature
Newbie Coder
(It's just a name)
> 1) How do I get a list of all users in a domain?
> I've searched the web, but any sample I've found seems to use VB 2003 or
[quoted text clipped - 6 lines]
> Thanks
> Vayse
Vayse - 30 Apr 2007 12:15 GMT
Thanks. This is failing for me, with an unknown error, on
users = group.Invoke("members")
I suspect I may have strDirEntryPath incorrect. Are "WinNT" and "Domain
Users" always part of the string?
If not, how would I find what should have instead?
Thanks
Vayse
> Vayse,
>
[quoted text clipped - 50 lines]
>> Thanks
>> Vayse