PingDirectory

Synchronizing a field of a JSON attribute into a non-JSON attribute

If the source stores:

ubidEmailJSON: {"value" : "jsmith@example.com", "type" : "home"}

But the destination stores:

mail: jsmith@example.com

To synchronize changes between these systems, configure a constructed attribute mapping:

$ bin/dsconfig create-attribute-mapping \
  --map-name "Attribute Map" \
  --mapping-name mail \
  --type constructed \
  --set "value-pattern:{contact.ubidEmailJSON.value}"
  • The value-pattern syntax allows attributes to be referenced by placing them in {}.

  • To reference JSON fields within the attribute, use the syntax {attribute.field}.

Learn more in the configuration documentation included with the server or by running bin/dsconfig --help-sync.

The value-pattern property supports references to JSON fields that are multiple levels deep. For example, if a source attribute contact contains a nested JSON object with an ubidEmailJSON field, you can reference the value field within the object by using the following pattern:

value-pattern:{contact.ubidEmailJSON.value}

When a value-pattern path passes through a JSON array, the array is automatically expanded to produce multiple attribute values. This behavior is not configurable. For example, if someAttribute has the value:

{"a": [{"b": "b value 1"}, {"b": "b value 1"}]}

Then applying the pattern {someAttribute.a.b} produces two values:

b value 1
b value 1

When it’s unclear whether a dot is a character in the JSON field name or a separator between JSON field names, the parser favors a literal dot in the field name over the dot being a path separator.

After you create the attribute map, you can reference it from the sync class:

$ bin/dsconfig set-sync-class-prop \
  --pipe-name "A to B" \
  --class-name Users \
  --set "attribute-map:Attribute Map"

Troubleshooting

While LDAP attribute names are not case sensitive, the JSON field names are. By default, errors related to attribute mapping are not logged. To enable error logging, configure the Debug Logger with the following:

$ bin/dsconfig set-log-publisher-prop \
  --publisher-name "File-Based Debug Logger" \
  --set enabled:true
$ bin/dsconfig create-debug-target \
  --publisher-name "File-Based Debug Logger" \
  --target-name com.unboundid.directory.sync.mapping \
  --set debug-level:warning