Error coming up when no groups found.

Home Forums Scripting General Scripting Error coming up when no groups found.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    wullieb1
    Participant
    #128202

    Where do i start.

    We are having a clear out of our AD domain, believe it or not but we have 500 users and 450 groups, so i was writing, well stealing really, a script whereby i can get a list of all the domain users, dump that to a file and then use the file to then enter the distinguished name so i can check for groups.

    Bit long winded i know but it works for me and i can tweak it at a later date.

    So what happens is that when i come across a user the script bombs out because the memberOf protion in AD is empty.

    I have some code that sort of works around it a little bit but it will only do the first hit before failing on me.

    The error code is 424.

    The code is

    ‘open the data file
    Set objTextStream = objFSO.OpenTextFile(“.user.txt”)
    ‘make an array from the data file
    arrUser = Split(objTextStream.ReadAll, vbNewLine)
    ‘close the data file
    objTextStream.Close

    For i = LBound(arrUser) To UBound(arrUser)
    ‘Connect to AD as user
    strLDAP = “LDAP://” & arrUser(i)
    Set objUser = GetObject(strLDAP)
    objmemberOf = objUser.GetEx(“memberOf”)
    Do while err.number <> 424
    If err.number = vbEmpty then
    For Each objGroup in objmemberOf
    objGroup = Mid(objGroup, 4, 330)
    arrGroup = Split(objGroup, “,” )
    strList = strList & arrGroup(0) & vbCr
    Next
    End If
    Loop
    wscript.echo strList
    Next[/CODE]

    I’m still working on this so it may change and any changes i make i will post up new code.

    This is the part that i can’t get to work and everything else works perfectly.[CODE]’open the data file
    Set objTextStream = objFSO.OpenTextFile(“.user.txt”)
    ‘make an array from the data file
    arrUser = Split(objTextStream.ReadAll, vbNewLine)
    ‘close the data file
    objTextStream.Close

    For i = LBound(arrUser) To UBound(arrUser)
    ‘Connect to AD as user
    strLDAP = “LDAP://” & arrUser(i)
    Set objUser = GetObject(strLDAP)
    objmemberOf = objUser.GetEx(“memberOf”)
    Do while err.number <> 424
    If err.number = vbEmpty then
    For Each objGroup in objmemberOf
    objGroup = Mid(objGroup, 4, 330)
    arrGroup = Split(objGroup, “,” )
    strList = strList & arrGroup(0) & vbCr
    Next
    End If
    Loop
    wscript.echo strList
    Next[/CODE]

    I’m still working on this so it may change and any changes i make i will post up new code.

    This is the part that i can’t get to work and everything else works perfectly.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.