Directory Services

Creating an ADAM Application Directory Partition

[This documentation is preliminary and subject to change.]

To create an application directory partition for ADAM, bind to an ADAM instance, create an appropriate object type for the partition, set properties for the partition, and save the new partition to the ADAM instance.

You can delete the application directory partition you create with the following code example by Deleting an ADAM Application Directory Partition.

The following VBScript code example uses the GetObject function to connect to the LDAP provider, uses the OpenDSObject method to bind to an ADAM instance on a server, uses the Create method to create an organization type application directory partition, and sets the instanceType and description properties of the partition.

' Create ADAM Application Directory Partition.

' To create a container ADP:
' Use, for example, "O=Fabrikam,C=US" in ADAMsPath.
' Use ADS_USE_DELEGATION | ADS_SECURE_AUTHENTICATION
'  in OpenDSObject().
' Use "container" in Create().
'
' To create an organization ADP:
' Use, for example, "C=US" in ADAMsPath.
' Use ADS_USE_DELEGATION | ADS_FAST_BIND |
'  ADS_SECURE_AUTHENTICATION in OpenDSObject().
' Use "organization" in Create().

' Currently configured to create an "organization" ADP.

Option Explicit

Const ADS_SECURE_AUTHENTICATION =   1
Const ADS_FAST_BIND			 =  32
Const ADS_USE_DELEGATION		= 256

Const DS_INSTANCETYPE_IS_NC_HEAD	= 1
Const DS_INSTANCETYPE_NC_IS_WRITEABLE = 4

Dim objADAM		 ' Partition parent.
Dim objADP		' Partition.
Dim objLDAP		 ' LDAP provider.
Dim strADP		' Partition name.
Dim strDescription  ' Partition description.
Dim strPath		 ' Binding path.

' Construct ADAMsPath binding string.
' Change "localhost" to appropriate server.
' Change "389" to port for appropriate instance.
' Change "C=US" to appropriate object.
strPath = "LDAP://localhost:389/C=US"

WScript.Echo "Bind to: " & strPath

' Specify application directory partition.
strADP = "O=Fabrikam"
strDescription = "ADAM Application Directory Partition"

WScript.Echo "Create:  Partition " & strADP
WScript.Echo "		 " & strDescription

' Create LDAP provider.
Set objLDAP = GetObject("LDAP:")

' Bind to ADAM server.
' Use ADS_USE_DELEGATION | ADS_SECURE_AUTHENTICATION
'  for container.
' Use ADS_USE_DELEGATION | ADS_FAST_BIND |
'  ADS_SECURE_AUTHENTICATION for organization.
Set objADAM = objLDAP.OpenDSObject(strPath, _
				vbNullString, vbNullString, _
				ADS_USE_DELEGATION Or ADS_FAST_BIND _
				Or ADS_SECURE_AUTHENTICATION)

' Create partition object.
' Use "container" for CN= partition.
' Use "organization" for O= partition.
Set objADP = objADAM.Create("organization", strADP)

' Set instanceType property of partition.
' Use DS_INSTANCETYPE_IS_NC_HEAD | DS_INSTANCETYPE_NC_IS_WRITEABLE
'  for application partition directory.
objADP.Put "instanceType", DS_INSTANCETYPE_IS_NC_HEAD _
			 Or DS_INSTANCETYPE_NC_IS_WRITEABLE

' Set description property of partition.
objADP.Put "description", strDescription

' Commit new partition to server.
objADP.SetInfo

WScript.Echo "Success: Created " & objADP.ADsPath