Passing MultiValued Attribute Named as proxyAddresses to AD through BeforeProvisioning Cloud Rule

Problem

While passing the proxyAddresses through Before Provisioning Cloud Rule, getting the Runtime Exception while provisioning to AD but as soon as we remove the attribute from before provisioning rule, the AD provisioning is working as expected.

Diagnosis

The issue was the way the proxyAddresses attribute was getting passed in the before provisioning rule as String variable type. Refer the below snippet of the code.

String proxyAddresses = null;
proxyAddresses = "SMTP:[email protected],smtp:[email protected]";
accountRequest.add(new AttributeRequest("proxyAddresses",ProvisioningPlan.Operation.Add,proxyAddressesList));

Note the proxyAddresses is muti-valued attribute and hence, passing the data of proxyAddresses as String is definitely not going to work and it will throw a runtime exception of incompatible datatype.

Solution

The way your code will work while calculating and passing the proxyAddresses in before provisioning rule is as follows.

List proxyAddresses = new ArrayList();
proxyAddresses.put("SMTP:[email protected]");
proxyAddresses.put("smtp:[email protected]");
accountRequest.add(new AttributeRequest("proxyAddresses",ProvisioningPlan.Operation.Add,proxyAddressesList));

You have to declare the proxyAddresses variable of type List and instantiate with ArrayList.

Once you add the required primary and secondary addresses to the proxyAddresses variable of type list, you can add it to the accountRequest object.

In this way, the provisioning will work as expected while manipulating and passing proxyAddresses as list in before provisioning rule.