OpenDsObject example (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
-->
<HEAD>
<TITLE>Successful Organizational Unit Creation</TITLE>
</HEAD>

<BODY>
<%
  strPath = "LDAP://dc=mycorp,dc=com"
  strUsername = "cn=Administrator,cn=Users,dc=mycorp,dc=com"
  strPassword = "my-admin-password"

  Set objNamespace = GetObject("LDAP:")
  Set objRoot = objNamespace.OpenDSObject(strPath, strUsername, strPassword, 0)

  Set objSalesOU = objRoot.Create("organizationalUnit","ou=Sales")
  objSalesOU.Description = "My new description!"
  objSalesOU.SetInfo

  Response.Write "The Sales OU has been created in the " & strPath & " domain."
%>
</BODY>
</HTML>

This code has been viewed 4295 times.

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