evaluating members inside a AD group RRS feed

  • Question

  • If I have an AD group with members, and one of the members is another group, how can I tell it is a group in vbscript?



    • Moved by Jie Bao Thursday, January 26, 2012 2:49 AM (From:Visual Basic Language)
    Tuesday, January 24, 2012 2:46 PM


  • This forum is not for vbscripting quesitons. I apologize, I do not have the correct link for the vbscript forum.

    If you were looking for a .Net solution, see the following code I have from an old project:

    Imports System.DirectoryServices<br/>Imports System.IO<br/><br/>        'Dim new active directory instance
            Dim NewAD As DirectoryEntry = New DirectoryEntry("LDAP://" & MyDomain)
            'Create user filter with username
            Dim UserFilter As String = "(SAMAccountName=" & ADUser & ")"
            'Create directory searcher, give it directory to search and search criteria
            Dim FindUser As New DirectorySearcher(NewAD, UserFilter)
            'Create collection of all found users
            Dim SearchResults As SearchResultCollection = FindUser.FindAll
            'Loop through each result (user) found
            For Each result As SearchResult In SearchResults
                'Loop through each property for the user found
                For Each ADProperty As DictionaryEntry In result.Properties
                    'For each property that has a value
                    For Each IndividualValue As Object In ADProperty.Value
                        If ADProperty.Key.ToString = "memberof" Then
                            'This is where the searcher returns the groups. They are in a long string separated by commas,
                            'so you will have to separate them manually
                        End If

    Now this coding actually pulls all of the available user information from the active directory, since that's what I needed for my project. You can actually add criteria to the searcher so it only pulls the groups. I do not have that specific coding, but you should be able to find it quickly searching on the MSDN under the AD class.


    Tuesday, January 24, 2012 4:56 PM