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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OU creation help

Status
Not open for further replies.

Trekk

Programmer
Aug 16, 2001
66
US
I have some code that will create an Active Directory OU underneedth the parent OU, however I need it to go one level deeper.

My directory structure is setup with the following OUs

Domain OU
Department OU
and then the departments(this is where I need the new OU to be created

Example: domain\department\IT
domain\department\HR
domain\department\Finance

' This code creates an OU
' ------ SCRIPT CONFIGURATION ------
strOrgUnit = "test44" ' e.g. Tools
strOrgUnitParent = "ou=Domain,dc=adts,dc=lan" ' e.g. ou=BioPort,ou=departments,dc=adts,dc=lan
strOrgUnitDescr = "testou" ' e.g. Tools Users
' ------ END CONFIGURATION ---------

set objDomain = GetObject("LDAP://" & strOrgUnitParent)
set objOU = objDomain.Create("organizationalUnit", "OU=" & strOrgUnit)
objOU.Put "description", strOrgUnitDescr
objOU.SetInfo
WScript.Echo "Successfully created " & objOU.Name
 
Hello Trekk,

The general pattern of creating a child ou within an ou is like you've already. Only you have then to bind to the ou parent one-level below of where you're right now. Or, maybe I miss the point.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top