Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Policy map scripts

Control whether an attribute is written to a managed system and what value it carries — isPerform, perform, the diff object, and an annotated shipped example.

Applies to: OpenIAM 2026.8.1

A policy map script decides whether an attribute is written to a managed system, and what value it carries. One script per attribute, per managed system.

This is the type you will write most. Across the scripts shipped with the platform, AbstractIPolicyMapGroovy accounts for more than five times the next most common base class. If you learn one type properly, learn this one.

What this builds, and how long it takes

You get

A script controlling one attribute on one managed system

Time

An hour for a first script, including two provisioning runs

You need

A deployment, a configured managed system, and an account you can provision to it

Reversible

Yes — increment the version, or unbind the script from the policy map

Before you start

  • A test managed system. Provisioning a wrong value to a production directory is not something a script version helps with.

  • A decision about who owns this attribute after the account is created — OpenIAM, or the target. That decision is what the script expresses.


Build it

1. Understand the two methods

isPerform is a gate. Return false and the attribute is not written at all. "Only on create", "only when the department changed" and "never for contractors" live here.

perform supplies the value. It is only called when isPerform returned true.

Splitting them is the point. Not writing an attribute and writing it empty are different things to a target system — one leaves the existing value alone, the other clears it.

2. Know what the diff object tells you

The type parameter is the diff:

Type
For

ProvisionUserObjectDiff

User provisioning

ProvisionGroupObjectDiff

Group provisioning

Member
Gives you

getStatus()

An AttributeOperationEnum — ADD, REPLACE, DELETE, NO_CHANGE

getLeft()

The object being provisioned

userRoleDiffs and similar

Per-membership diffs, each answering isDirty()

getStatus() is how you distinguish a create from an update. AttributeOperationEnum.ADD is a new account.

3. Use what the base class injects

AbstractIPolicyMapGroovy provides these as protected fields — no @Autowired needed:

Field
Is

ctx

The Spring ApplicationContext

managedSysId

The managed system being provisioned to

loginMQService

Login lookups

userMQService

User lookups

propertyValueService

Cached property values

counterRabbitMQService

Counters, for generated values

mapper

A configured Jackson mapper

4. Write it

StringOperationalConnectorValue carries the operation as well as the value. Passing diffObject.getStatus() is what tells the connector whether this is an add or a replace. Get it wrong and a value that should be replaced is appended instead.

5. Read a shipped example

conf/iamscripts/provision/ad/group/Description_1.0.groovy, complete:

Twenty-three lines, and every one earns its place. Read isPerform: this script writes the description only when the group is created. On an update it returns false, so whatever the directory holds is left alone. That is a deliberate decision — the directory is treated as authoritative for the description after creation — and it is expressed in one line.

That is the pattern to copy. Decide who owns each attribute after creation, and say so in isPerform.

6. Write only when something changed

For an attribute that should follow OpenIAM on every change, gate on the diff rather than the operation:

From conf/iamscripts/provision/test-h2/memberOf_1.0.groovy. Always write on create; on update, write only if something in the relevant collection actually moved. Without that second line, every provisioning event rewrites the whole membership set.

7. Deploy it

  1. Groovy Manager → the folder under provision/ for your managed system.

  2. New Script, named for the attribute it maps — the shipped scripts use the target's attribute name: cn, memberOf, userPrincipalName.

  3. Save. It compiles on save.

  4. Reference it from the managed system's policy map, against the attribute.


Verify it

Provision one account to a test managed system, then change one attribute and provision again. The two runs together tell you what one cannot.

Check
Expect

Create

The attribute present in the target with the right value

Update, attribute unchanged

isPerform returned false — nothing written

Update, attribute changed

The value replaced, not appended

The connector log

The attribute and operation your script produced

If it goes wrong

What you see
What it means
What to do

The attribute is never written

isPerform returns false

Log diffObject.getStatus() at the top of it

The attribute is written on every event

isPerform returns true unconditionally

Gate on the status, or on isDirty()

Values accumulate instead of replacing

The operation is not passed with the value

Pass diffObject.getStatus() into StringOperationalConnectorValue

NullPointerException in perform

The source field is null

Guard in isPerform — that is what it is for

The value is right but the target rejects it

Format the target expects

Compare against the shipped script for that target

A membership set is rewritten every time

No isDirty() check

Add the diff gate in step 6

What this procedure does not cover

Configuring the managed system and its policy map, which is the Administration Guide's subject. Connector behavior, and what a specific target does with a value once it receives it.

Last updated

Was this helpful?