Results 1 to 2 of 2

Thread: VBScripting help     submit to reddit submit to twitter

  1. #1
    Ridill
    Join Date
    Feb 2008
    Posts
    10,418
    BG Level
    9

    VBScripting help

    I need a VBScript to pull "member of" info from AD. I want to make a txt file of the users names and then have the vbscript pull from that txt file so i don't have to do individual ones. this is what I was thinking of using but don't know what edit to pull from the .txt file. We'll call it "users.txt". Any help would be appreciated. Thanks!

    On Error Resume Next
    Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D

    Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com" )

    intPrimaryGroupID = objUser.Get("primaryGroupID")
    arrMemberOf = objUser.GetEx("memberOf")

    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "The memberOf attribute is not set."
    Else
    WScript.Echo "Member of: "
    For each Group in arrMemberOf
    WScript.Echo Group
    Next
    End If

    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"
    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection
    objCommand.CommandText = _
    ";(objectCategory=Group);" & _
    "distinguishedName,primaryGroupToken;subtree"
    Set objRecordSet = objCommand.Execute

    While Not objRecordset.EOF
    If objRecordset.Fields("primaryGroupToken") = intPrimaryGroupID Then
    WScript.Echo "Primary group:"
    WScript.Echo objRecordset.Fields("distinguishedName") & _
    " (primaryGroupID: " & intPrimaryGroupID & ")"
    End If
    objRecordset.MoveNext
    Wend

    objConnection.Close

  2. #2
    Bagel
    Join Date
    Jan 2006
    Posts
    1,428
    BG Level
    6

    VBScript sucks