Hi all
I need to create a security group with all of the members of a distribution group. The distribution group is populated nightly by a program called SmartDL. I am able to grab all of the users from the distribution group and save them to a text file. When i try to add the users from the text file to my security group, i get an error saying "error: Object Required" then lists the users name. It errors after the first user. Can anyone help? Thanks.
I need to create a security group with all of the members of a distribution group. The distribution group is populated nightly by a program called SmartDL. I am able to grab all of the users from the distribution group and save them to a text file. When i try to add the users from the text file to my security group, i get an error saying "error: Object Required" then lists the users name. It errors after the first user. Can anyone help? Thanks.
Code:
'==========================================================================
'
' NAME: Populate IST Project Group.vbs
'
' AUTHOR: Gene Magerr
' EMAIL: genemagerr@hotmail.com
'
' COMMENT:
'
'==========================================================================
Option Explicit
'==========================================================================
' VARIABLE DECLARATIONS
'==========================================================================
Dim objFSO, arrMemberOf, objGroup, objFileNew, objFile, objUserS
Dim objGroupNew, arrUserList, strNewUser, TestMode, strMember
Set objFSO = CreateObject("Scripting.FilesystemObject")
'==========================================================================
' STATIC VARIABLE ASSIGNMENTS
'==========================================================================
Const FOR_READING = 1, FOR_WRITING = 2, FOR_APPENDING = 8
'==========================================================================
' MAIN SCRIPT CODE
'==========================================================================
Set objGroup = GetObject("LDAP://cn=All IST Members,ou=groups,dc=company,dc=com")
objGroup.GetInfo
arrMemberOf = objGroup.GetEx("member")
If Not objFSO.FileExists("c:\ist_new.txt") Then
objFSO.CreateTextFile("c:\ist_new.txt")
End If
Set objFileNew = objFSO.OpenTextFile("c:\ist_new.txt",2, True)
For Each strMember in arrMemberOf
Set objUserS = GetObject("LDAP://" & strMember)
objUserS.GetInfo
objFileNew.WriteLine(objUserS.Get("displayName"))
Next
objFileNew.Close
Set objFile = objFSO.OpenTextFile("c:\ist_new.txt",1)
Set objGroupNew = GetObject("LDAP://cn=_genetest,ou=groups,dc=company,dc=com")
Do Until objFile.AtEndOfStream
strNewUser = objFile.Readline
arrUserList = Split(strNewUser , vbCrLf)
For Each strNewUser In arrUserList
WScript.Echo strNewUser
objGroupNew.add strNewUser.adspath
Next
Loop