The following code shows how to use the API service to create, read, update, and delete single domains (security domains) using the IDomain interface:

define variable domain as IDomain no-undo.

domain = service:NewDomain("MyDomain").
/* Set properties and optionally add elements to collections */
. . .
service:CreateDomain(domain).

. . .
domain = service:GetDomain("MyDomain").
/* Set properties */
service:UpdateDomain(domain).

. . .
service:DeleteDomain("MyDomain").

For more information on security domains, see Introduction to Identity Management.

It is also possible to retrieve a collection of domains in the database from the service and then do create, read, update and/or delete on domains in the IDomainSet collection before passing the collection to the service to be committed in a single transaction:

define variable domainSet as IDomainSet no-undo.

domainSet = service:GetDomains().

domain = service:NewDomain("SomeDomain").
/* Set properties and optionally add elements to collections */
. . .
domainSet:Add(domain).

. . .
domain = domainSet:Find("XDomain")
domain:IsEnabled = true.

domain = domainSet:Find("ZDomain")
domainMap:Remove(domain).

service:UpdateDomains(domains).

For more information on the: