Announcement

Collapse
No announcement yet.

Script for Finding All members of various groups in an OU

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script for Finding All members of various groups in an OU

    I have searched the Forum for something like what i require but am having trouble getting this to work

    i need to search an OU called LIVE which is buried a few levels deep in our AD structure

    ---Details----
    The conical name of the OU is as follows :
    norfolk.police.uk/Permissions Groups and Users/In House Applications/CIS/Live

    I have tried to run the following script
    ------------
    On Error Resume Next

    Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D

    Set objOU = GetObject _
    ("LDAP://cn=live,dc=norfolk,dc=police.uk")

    ObjOU.Filter= Array("user")

    For Each objUser in objOU
    WScript.Echo objUser.cn & " is a member of: "
    WScript.Echo vbTab & "Primary Group ID: " & _
    objUser.Get("primaryGroupID")

    arrMemberOf = objUser.GetEx("memberOf")

    If Err.Number <> E_ADS_PROPERTY_NOT_FOUND Then
    For Each Group in arrMemberOf
    WScript.Echo vbTab & Group
    Next
    Else
    WScript.Echo vbTab & "memberOf attribute is not set"
    Err.Clear
    End If
    Wscript.Echo
    Next

    It outputs nothing.............
    Should I be adding more CN or OU entries to define where the search is to take place. ?

    Any help appreciated - Also how would I output this to a txt file ?

    once again - thanks for any help you can offer.
    Regards
    Wazzie

  • #2
    Re: Script for Finding All members of various groups in an OU

    The path must be entered in full starting with Live...

    so it's as follows:

    CN=Live,CN=CIS,CN=In House Applications,CN=Permissions Users and Groups,DC=norfolk,DC=police,DC=uk

    Note that the domain is the RIGHT way round, the OU structure is BACKWARDS.


    Tom
    For my own and your protection, I do not provide support by private message under any circumstances. All such messages will be deleted and ignored.

    Anything you say will be misquoted and used against you

    Comment

    Working...
    X