danthony2
2009-09-02 20:52:48 UTC
I have been at this for a couple of hours and just can't figure what i
going wrong.
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
-------------------
If anyone can point me to my error that would be great. The script run
but doesn't create the group.
Thanks,
Davi
--
danthony
-----------------------------------------------------------------------
danthony2's Profile: http://forums.techarena.in/members/116955.ht
View this thread: http://forums.techarena.in/server-scripting/1241195.ht
http://forums.techarena.i
going wrong.
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
-------------------
If anyone can point me to my error that would be great. The script run
but doesn't create the group.
Thanks,
Davi
--
danthony
-----------------------------------------------------------------------
danthony2's Profile: http://forums.techarena.in/members/116955.ht
View this thread: http://forums.techarena.in/server-scripting/1241195.ht
http://forums.techarena.i