ADSI

M

Mr Newbie

Does anyone have any experience in getting information on users in the
Active Directory Services. I am trying to get information on the users at a
basic level like their username, email, firstname etc.

I have managed to get pretty much username only and a few other useless
bits of information. Here is my code so far. With this I manage to get the
basic names of all the Domain Users group. But I need to know how to get the
other stuff. I've dug around but not yet found anything which helps.!

Any help would be appreciated.
--------------------------------------------------------

Public Shared Function ReturnUsers() As System.Collections.ArrayList
Dim strDirEntryPath As String
strDirEntryPath = "WinNT://MyDomain/Domain Users,group"


Dim users As Object

Dim group As New DirectoryEntry(strDirEntryPath, "CommonUser",
"password")
users = group.Invoke("members")

Dim user1 As Object
Dim UsersCollection As New ArrayList(300)

For Each user1 In CType(users, IEnumerable)
Try
Dim userEntry As New
System.DirectoryServices.DirectoryEntry(user1)
UsersCollection.Add(userEntry.Name)

Catch e1 As Exception
Throw
Return nothing
End Try
Next

Return UsersCollection
End Function
 
D

David Lloyd

The following MSDN article give a sample of how to iterate through the
properties of the DirectoryEntry class.

http://msdn.microsoft.com/library/d.../html/vbwlkwalkthroughcreatingadsiobjects.asp

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


Does anyone have any experience in getting information on users in the
Active Directory Services. I am trying to get information on the users at a
basic level like their username, email, firstname etc.

I have managed to get pretty much username only and a few other useless
bits of information. Here is my code so far. With this I manage to get the
basic names of all the Domain Users group. But I need to know how to get the
other stuff. I've dug around but not yet found anything which helps.!

Any help would be appreciated.
--------------------------------------------------------

Public Shared Function ReturnUsers() As System.Collections.ArrayList
Dim strDirEntryPath As String
strDirEntryPath = "WinNT://MyDomain/Domain Users,group"


Dim users As Object

Dim group As New DirectoryEntry(strDirEntryPath, "CommonUser",
"password")
users = group.Invoke("members")

Dim user1 As Object
Dim UsersCollection As New ArrayList(300)

For Each user1 In CType(users, IEnumerable)
Try
Dim userEntry As New
System.DirectoryServices.DirectoryEntry(user1)
UsersCollection.Add(userEntry.Name)

Catch e1 As Exception
Throw
Return nothing
End Try
Next

Return UsersCollection
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top