Create OU (ASP)

This code can be found in Chapter 28 of Active Directory, 3rd Edition

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the ASP code from this site.

<HTML>
<!--
' From the book "Active Directory, Third Edition" 
' ISBN: 0-596-10173-2
-->
<HTML>
<HEAD>
<TITLE>Example use of Complex Authentication</TITLE>
</HEAD>
   
<BODY>
<%
  strRootPath = "LDAP://dc=mycorp,dc=com"
  strUserPath  = "LDAP://cn=Ian Harcombe,cn=Users,dc=mycorp,dc=com"
  strUsername = "mycorp\administrator"
  strPassword = "My-admin-password!"
   
  Set objNamespace = GetObject("LDAP:")
  Set objRoot = objNamespace.OpenDSObject(strRootPath,strUsername,strPassword,0)
   
  Set objSalesOU = objRoot.Create("organizationalUnit","ou=Sales")
  objSalesOU.Description = "My new description!"
  objSalesOU.SetInfo
   
  Set objUser = objNamespace.OpenDSObject(strUserPath,strUsername,strPassword,0)
  objUser.Description = "My new description!"
  objUser.SetInfo
%>
</BODY>
</HTML>

This code has been viewed 1910 times.

New from the creators of TechTasks.com: StatSheet.com