CreateZone

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

Syntax

IZone CreateZone(IADs container, string name)

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. You can use the standard ADSI GetObject function to retrieve this interface.

name

The name of the new zone.

Return value

The zone object and its related data as Centrify.DirectControl.API.IZone.

Discussion

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

Exceptions

CreateZone 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 hierarchical zone named Sample_Zone in the parent container Program Data/Centrify/Zones:

...
string strParent = "CN=zones,CN=Centrify,CN=Program Data";
string strZone = "sample_zone";
// Create a CIMS object to interact with AD.
Cims cims = new Cims();
// Note the lack of the cims.connect function.
// By default, this script will use the connection to the domain controller
// and existing credentials from the computer already logged in.
// Obtain an active directory container object.
DirectoryEntry objRootDSE = new DirectoryEntry("LDAP://rootDSE");
DirectoryEntry objContainer = new DirectoryEntry("LDAP://" + strParent + "," +      objRootDSE.Properties["defaultNamingContext"].Value.ToString());
IHierarchicalZone objZone = cims.CreateZone(objContainer, strZone) as IHierarchicalZone;
...