Creating Global Groups from a text file

Home Forums Scripting General Scripting Creating Global Groups from a text file

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #144234

    I have been at this for a couple of hours and just can’t figure what is going wrong.

    ‘==========================================================================
    ‘ AUTHOR: David R
    ‘ DATE : 9/2/2009
    ‘==========================================================================

    Const ForReading = 1

    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objTextFile = objFSO.OpenTextFile _
    (“davidtestgrlst.txt”,ForReading)

    strText = objTextFile.ReadAll

    objTextFile.Close

    arrGroups = Split(strText, vbCrLf)

    Dim objAD, objGroup, objNewGroup, objUser, objRootDSE
    Dim objDomain, objOU
    Dim strGroup, strNewGroup, strPath, strUser
    Dim strOU, strDNSDomain
    Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
    Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

    Set objRootDSE = GetObject(“LDAP://RootDSE”)
    strDNSDomain = objRootDSE.Get(“DefaultNamingContext”)
    strOU =”OU=LDAPApplications,OU=Groups,”

    strPath =”LDAP://” & strOU & strDNSDomain
    Set objOU = GetObject(strPath)

    For Each strGroup in arrGroups

    On Error Resume Next

    Set objNewGroup = objOU.Create(“Group”, “cn=”& GroupName)
    objNewGroup.Put “sAMAccountName”, strGroup
    objNewGroup.Put “groupType”, ADS_GROUP_TYPE_GLOBAL_GROUP Or _
    ADS_GROUP_TYPE_SECURITY_ENABLED
    objNewGroup.SetInfo

    Next

    [/CODE]

    If anyone can point me to my error that would be great. The script runs but doesn’t create the group.

    Thanks,
    David[CODE]
    ‘==========================================================================
    ‘ AUTHOR: David R
    ‘ DATE : 9/2/2009
    ‘==========================================================================

    Const ForReading = 1

    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objTextFile = objFSO.OpenTextFile _
    (“davidtestgrlst.txt”,ForReading)

    strText = objTextFile.ReadAll

    objTextFile.Close

    arrGroups = Split(strText, vbCrLf)

    Dim objAD, objGroup, objNewGroup, objUser, objRootDSE
    Dim objDomain, objOU
    Dim strGroup, strNewGroup, strPath, strUser
    Dim strOU, strDNSDomain
    Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
    Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

    Set objRootDSE = GetObject(“LDAP://RootDSE”)
    strDNSDomain = objRootDSE.Get(“DefaultNamingContext”)
    strOU =”OU=LDAPApplications,OU=Groups,”

    strPath =”LDAP://” & strOU & strDNSDomain
    Set objOU = GetObject(strPath)

    For Each strGroup in arrGroups

    On Error Resume Next

    Set objNewGroup = objOU.Create(“Group”, “cn=”& GroupName)
    objNewGroup.Put “sAMAccountName”, strGroup
    objNewGroup.Put “groupType”, ADS_GROUP_TYPE_GLOBAL_GROUP Or _
    ADS_GROUP_TYPE_SECURITY_ENABLED
    objNewGroup.SetInfo

    Next

    [/CODE]

    If anyone can point me to my error that would be great. The script runs but doesn’t create the group.

    Thanks,
    David

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.