"Clubsprint" <> wrote in message
news:gaqbjt$s6b$...
> G'day all
> I've hobled a script together from the MS examples but it's not working.
> I want to create a list of groups in an OU.
> I run the script and it asks for the input and then does nothing.
>
> ------start script--------
>
> On Error Resume Next
>
> Dim OrgUnit, GroupName, fso, f, objOU, objGroup
>
> Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
> Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000
>
> GroupName = InputBox("Enter the name of the Group Name you wish to
> create")
>
> Set objOU = GetObject("LDAP://ou=Workstation
> Groups,ou=Workstations,dc=int,dc=dept,dc=gov")
> Set objGroup = objOU.Create("Group", "cn=ChairmanWS")
>
> objGroup.Put "sAMAccountName", "HRStaff"
> objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _
> ADS_GROUP_TYPE_SECURITY_ENABLED
> objGroup.SetInfo
>
> ------start script--------
>
>
> what does the part
> objGroup.Put "sAMAccountName", "HRStaff"
> do? I'm not sure how to change this to make it relevent to my site
> I'd really like to create the groups from a list in a text file but I've
> not beenn able to work that out
>
> thanks in advance
>
First, remove "On Error Resume Next". There is no need for it here and it
suppresses error messages. This makes troubleshooting nearly impossible.
The statement you refer to assigns the value "HRStaff" to the sAMAccountName
attribute. This attribute must have a value that is unique in the domain.
The statement that creates the group assigns a value to the cn attribute
(Common Name). This value must be unique in the OU.
A likely problem is that you have run the script more than once and an error
was raised when you attempted to create a group with duplicate cn or
sAMAccountName. Notice that you prompt for GroupName, but then never use it.
Perhaps you want to use (watch line wrapping):
==============
Option Explicit
Dim GroupName, objOU, objGroup
Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000
GroupName = InputBox("Enter the name of the Group Name you wish to create")
Set objOU = GetObject("LDAP://ou=Workstation
Groups,ou=Workstations,dc=int,dc=dept,dc=gov")
Set objGroup = objOU.Create("Group", "cn=" & GroupName)
objGroup.Put "sAMAccountName", GroupName
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _
ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo
========
I added "Option Explicit" so you must declare all variables (in Dim
statements). This helps troubleshooting.
If you are creating groups from a list you can read names from a text file
using the FileSystemObject, then in the loop where you read each line of the
file (using the ReadLine method), create a group with each name (I would
check and skip blank lines, which are common in text files).
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--