Re: List nt-users and roles

From: Ian Harding (iharding160_at_hotmail.com)
Date: 10/28/03


Date: Tue, 28 Oct 2003 15:00:10 -0000


"PeterW" <anonymous@discussions.microsoft.com> wrote in message
news:0cfd01c39d53$e371fa90$a301280a@phx.gbl...
> Hi,
> I have a client-application that needs a list of all
> available users and roles in a domain on a server computer.
> So the first question is how to retrieve nt-users in
> vb.net? The second question is how to keep a database that
> contains these users updated as users change
> usernames/passwords?
> Thanks in advance!

Here is some code that populates two list controls, one with all users, the
other with all groups, from a named NT domain server:

Dim MyServer As System.DirectoryServices.DirectoryEntry
MyServer = New
System.DirectoryServices.DirectoryEntry("WinNT://<servername>")

MyServer.Children.SchemaFilter.Add("user")

For Each user As System.DirectoryServices.DirectoryEntry In
MyServer.Children
  lstUsers.Items.Add(user.Name)
Next

MyServer.Children.SchemaFilter.Clear()
MyServer.Children.SchemaFilter.Add("group")

For Each group As System.DirectoryServices.DirectoryEntry In
MyServer.Children
  lstGroups.Items.Add(group.Name)
Next

I'm not aware of any way of receiving updates from a non-Active Directory NT
domain when user information changes. If you can use Active Directory there
are a number of mechanisms, but I don't think they are available through the
.NET libraries so you will have to use unmanaged code. Take a look at
http://tinyurl.com/sott

Ian