Create script
Connectors continue to be released outside the IDM release. For the latest documentation, refer to the ICF documentation. |
A create script creates a new object on the external resource. If your connector does not support creating an object, this script should throw an UnsupportedOperationException
.
A sample create script for an SQL database is provided in openidm/samples/scripted-sql-with-mysql/tools/CreateScript.groovy
.
- Input variables
-
The following variables are available to a create script:
- configuration
-
A handler to the connector’s configuration object.
- options
-
A handler to the Operation Options.
- operation
-
An OperationType that corresponds to the action (
CREATE
). - objectClass
-
The object class that is created, such as
__ACCOUNT__
or__GROUP__
. - attributes
-
The set of attributes that describe the object to be created.
- id
-
The UID of the object to be created, if specified. If the UID is
null
, the UID should be generated by the server. The UID corresponds to the ICF__NAME__
attribute if it is provided as part of the attribute set. - log
-
A logger instance for the connector.
- Returns
-
The user unique ID (ICF
__UID__
) of the newly created object. Thetype
of the returned UID must be astring
or aUid
. If a null value or an object type other thanstring
orUid
is returned, the script must throw an exception.
def operation = operation as OperationType
def configuration = configuration as SapConfiguration
def log = log as Log
def objectClass = objectClass as ObjectClass
def createAttributes = new AttributesAccessor(attributes as Set<Attribute>)
def name = id as String
def options = options as OperationOptions
log.info("Entering {0} script",operation);
assert operation == OperationType.CREATE, 'Operation must be a CREATE'
// We only deal with users
assert objectClass.getObjectClassValue() == ObjectClass.ACCOUNT_NAME
def password = createAttributes.getPassword() as GuardedString;
assert password != null, 'Password must be provided on create'
//...
def uid = createTheUser(createAttributes);
return uid