Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb script to create security groups in nested ous

Status
Not open for further replies.

gblumberg2

IS-IT--Management
Feb 26, 2008
7
US
Hi, all i would like to write a script that reads from a txt file that would create multiple global security groups within a nested OU.

here is the script i am using to create one group within a nested ou.

Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objOU = GetObject("LDAP://ou=users_306,ou=Jacobs Heights III (306),ou=Properties,dc=domain,dc=com")
Set objGroup = objOU.Create("Group", "cn=maint_306")

objGroup.Put "sAMAccountName", "maint_306"
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _
ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo

I have 4 security groups that need to be created and one universal mail enabled distribution group that needs to be created as well for each nested OU

I have 90+ OUs to do this for.

any help would be appreciated, i currently have the data in an .xls file if i need to attach so you can see the names of the groups i am trying to create.

thanks in advance.
 
this may help as well, the groups the 4 groups that need to be created have this naming convention

lamsadmin_xxx(where xxx is a 3 digit number we use for accounting)
lamsca_xxx
lamsuser_xxx
maint_xxx

xxx CC Group that has an email address of receipt_xxx@domain.com (this is the mail enabled universal distribution group)
 
Here's a thought. Scan your AD recursive for all OU's LDAP names. NumStart = instr(txtofOUname,"OU=Users").
If numstart has a value, you've hit one of your target OUs.

If numstart <> 0 then use the Mid function, SomeNum=mid(txtofOUname,numstart + 10,3).

Now you have your #, make your 4(5?)groups one after the other, loop up to the top and test the next OU name.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top