locked
User Listing RRS feed

  • Question

  • User-1821657828 posted

    Can anyone guide me in acquiring a list of users names & email addresses from Active Directory? Especially if i can do so for specific group membership. This is for an application for a local intranet site.

     Thanks!

     Josh

    Thursday, October 5, 2006 5:25 PM

All replies

  • User-1821657828 posted

    I was able to get all users using the following script - i can't figure out how to get it to select by the memberof property:

    Public Function getAllUsers() As ArrayList

    Dim allUsers As New ArrayList()

    Dim searchRoot As New DirectoryEntry(LDAP://<domain>)

    Dim search As New DirectorySearcher(searchRoot)

    search.Filter = "(&(objectClass=user)(objectCategory=person))"

    search.PropertiesToLoad.Add("samaccountname")

    Dim result As SearchResult

    Dim resultCol As SearchResultCollection = search.FindAll()

    For i As Integer = 1 To resultCol.Count

    result = resultCol(i - 1)

    If (result.Properties.Contains("samaccountname")) Then

    allUsers.Add(result.Properties("samaccountname").Item(0))

    End If

    Next

    Return allUsers

    End Function

    Friday, October 13, 2006 8:32 PM