Listing10_Create_OU (VBScript)
This code can be found in
Chapter 7 of Managing Enterprise Active Directory Services
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4
ON ERROR RESUME NEXT
Dim user, passwd, server
server = "dc1"
user = "administrator@xyz.com"
passwd = "password"
' Get domain naming context
Dim rootDSE
set rootDSE = GetObject("LDAP://" & server & "/RootDSE")
Dim adsPath
adsPath = "LDAP://" & server & "/" & _
rootDSE.Get("defaultNamingContext") & ""
Dim ldapObj, domainObj
Set ldapObj = GetObject("LDAP:")
' Get domain object
Set domainObj = ldapObj.OpenDsObject(adsPath,user,passwd,1)
Dim ouObj
Set ouObj = domainObj.Create("organizationalUnit","OU=Employees")
ouObj.Put "description", "OU for XYZ Employee user accounts"
ouObj.SetInfo
If Err.Number then
Wscript.Echo "Error occurred when creating OU: " & Err.Description
Else
Wscript.Echo "OU Created"
End If
|
This code has been viewed 767 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|