CreateZoneWithSchema

Creates a zone with a specified schema type in the specified parent container and returns the zone object created.

Syntax

IZone CreateZoneWithSchema(IADs container, string name, int schema, int objectType)

Parameters

Specify the following parameters when using this method.

Parameter Description

container

The IADs interface of the parent container object to be used to store the new zone.

name

The name of the new zone.

schema

The schema type to use for the new zone. This parameter determines how the zone data is stored in Active Directory. For more information about the valid schema types you can specify, see Schema.

objectType

The Active Directory object type to use for the zone. The valid values are:

  • 0 defines the zone object as a Container object.
  • 1 defines the zone object as an Organization Unit.

Return value

The zone object as Centrify.DirectControl.API.IZone.

Discussion

The CreateZoneWithSchema function requires you to specify the Active Directory container object or organizational unit where the zone should be created. You can use the standard Active Directory GetObject function to retrieve the ADSI pointer to the specified container.

Exceptions

CreateZoneWithSchema may throw one of the following exceptions:

  • ArgumentNullException if the container object is a null reference.
  • ArgumentException if the zone name is invalid.
  • ApplicationException if a global catalog server error occurs.
  • UnauthorizedAccessException if the container object cannot be read because of insufficient permissions.
  • COMException if an LDAP error occurs. LDAP errors can occur if the connection to the LDAP server fails, the connection times out, invalid credentials are presented, or there are other problems communicating with Active Directory.

Example

The following code sample illustrates using this method in a script to create a new classic zone named ConsumerDiv as an organization unit in the parent container ajax.org/Corporate/Zones:

...
'Specify the parent container location for the zone
set objContainer = GetObject("LDAP://cn=Zones,cn=Corporate, dc=ajax,dc=org")
'Create a new zone named “ConsumerDiv”
set objZone = cims.CreateZoneWithSchema(objContainer, “ConsumerDiv”, 3, 1)
...

The GetObject call retrieves the ADSI pointer to the specified container.