README revision 49da166d507312f800a326215fea42407ce9bc25
257N/A/**
257N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
257N/A *
292N/A * Copyright (c) 2014 ForgeRock AS. All rights reserved.
257N/A *
257N/A * The contents of this file are subject to the terms
257N/A * of the Common Development and Distribution License
257N/A * (the License). You may not use this file except in
292N/A * compliance with the License.
292N/A *
292N/A * You can obtain a copy of the License at
292N/A * http://forgerock.org/license/CDDLv1.0.html
257N/A * See the License for the specific language governing
257N/A * permission and limitations under the License.
257N/A *
292N/A * When distributing Covered Code, include this CDDL
292N/A * Header Notice in each file and include the License file
292N/A * at http://forgerock.org/license/CDDLv1.0.html
292N/A * If applicable, add the following below the CDDL Header,
292N/A * with the fields enclosed by brackets [] replaced by
292N/A * your own identifying information:
292N/A * "Portions Copyrighted [year] [name of copyright owner]"
292N/A */
292N/A
292N/ASample 5b - "All-or-Nothing" Synchronization of Two Resources
292N/A-------------------------------------------------------------
257N/A
257N/AThis sample demonstrates flowing data between external resources just as
257N/Ain the regular sample 5 on which it is based. It simulates two directory
257N/Aresources using XML files. It extends sample 5 in that it configures a
257N/Acompensation script that attempts to ensure either all the synchronization
257N/Aor none of the synchronization is performed after making a change to a
257N/Amanaged user.
257N/A
257N/AWhenever a change is made to a managed/user resource, OpenIDM implicitly
257N/Aattempts to synchronize external resources according to the object mapping
257N/Ain sync.json where managed/user is the source. Typically, if the
257N/Asynchronization fails--owing to a policy validation for the target,
257N/Amissing required properties for the target, or simply that the target
257N/Ais unavailable--the synchronization stops, leaving the managed/user
257N/Aresource, and any targets that were synchronized before the failure,
257N/Aupdated. The target that failed, and any targets specified
257N/Ain mappings subsequent to the one that failed are not updated.
257N/AThis situation would usually result in a set of systems that are out of
257N/Async. The only way to re-synchronize them would be a reconciliation operation.
257N/AReconciliations can be expensive with large data sets.
257N/A
257N/AOpenIDM 3.0 enhances synchronization to multiple targets by providing
257N/Asynchronization details to an "onSync" script, after successfully synchronizing
257N/Aall targets or failing one target. This script hook can be used to "revert"
257N/Athe partial change to managed/user and the corresponding external resources
257N/Aper the object mappings.
257N/A
257N/ASample 5b includes a script that demonstrates compensating for a synchronization
257N/Afailure.
257N/A
257N/AFor documentation pertaining to this example see:
257N/Ahttp://openidm.forgerock.org/doc/install-guide/index.html#more-sample5b
257N/A
257N/ATo try the sample, follow these steps.
257N/A
257N/A Steps 1 and 2 are optional, and only necessary if you'd like to receive emailed
257N/A recon summaries.
257N/A
257N/A 1. Copy the samples/misc/external.email.json file into samples/sample5b/conf
257N/A $ cd /path/to/openidm
257N/A $ cp samples/misc/external.email.json samples/sample5b/conf
257N/A
257N/A Edit this file to have your email server SMTP details.
257N/A See http://openidm.forgerock.org/doc/integrators-guide/index.html#chap-mail
257N/A for more information.
257N/A
257N/A 2. Edit samples/sample5b/script/reconStats.js and change these values to your
257N/A own email addresses:
257N/A
257N/A var params = {
257N/A //UPDATE THESE VALUES
257N/A from : "openidm@example.com",
257N/A to : "idmadmin1@example.com",
257N/A cc : "idmadmin2@example.com,idmadmin3@example.com",
257N/A subject : "Recon stats for " + global.mappingName,
257N/A type : "text/html"
257N/A }
257N/A
257N/A 3. Start OpenIDM with the configuration for sample 5b.
257N/A $ cd /path/to/openidm
257N/A $ ./startup.sh -p samples/sample5b
257N/A When you start OpenIDM, it creates data in the new external resource file
257N/A that represents an AD directory, samples/sample5b/data/xml_AD_Data.xml.
257N/A The new file is empty until you run reconciliation.
257N/A
257N/A 4. Run reconciliation.
257N/A $ curl -k -H "Content-type: application/json" -u "openidm-admin:openidm-admin" -X POST "https://localhost:8443/openidm/recon?_action=recon&mapping=systemLdapAccounts_managedUser"
257N/A {"_id":"b149f0e3-4bb9-4790-9266-fab2e5c80ec6","state":"ACTIVE"}
257N/A
257N/A 5. Check
257N/A $ cat /path/to/openidm/samples/sample5b/data/xml_AD_Data.xml
257N/A <?xml version="1.0" encoding="UTF-8"?>
257N/A <icf:OpenICFContainer xmlns:icf="http://openidm.forgerock.com/xml/ns/public/resource/openicf/resource-schema-1.xsd"
257N/A xmlns:ri="http://openidm.forgerock.com/xml/ns/public/resource/instances/resource-schema-extension"
257N/A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
257N/A xsi:schemaLocation="http://openidm.forgerock.com/xml/ns/public/resource/instances/resource-schema-extension samples/sample5b/data/resource-schema-extension.xsd http://openidm.forgerock.com/xml/ns/public/resource/openicf/resource-schema-1.xsd samples/sample5b/data/resource-schema-1.xsd">
257N/A <ri:__ACCOUNT__>
257N/A <ri:firstname>Darth</ri:firstname>
257N/A <icf:__DESCRIPTION__/>
257N/A <icf:__GROUPS__/>
257N/A <icf:__UID__>68077c05-32ae-4438-b250-d23be784ea07</icf:__UID__>
257N/A <icf:__NAME__>DDOE1</icf:__NAME__>
257N/A <ri:email>mail1@example.com</ri:email>
257N/A <icf:__PASSWORD__>initial_Passw0rd</icf:__PASSWORD__>
257N/A <icf:__ENABLE__/>
257N/A <ri:lastname>Doe</ri:lastname>
257N/A </ri:__ACCOUNT__>
257N/A </icf:OpenICFContainer>
257N/A
257N/A 6. Create a new user in the source external resource file,
257N/A samples/sample5b/data/xml_LDAP_Data.xml, and run reconciliation again
257N/A to see the result show up in samples/sample5b/data/xml_AD_Data.xml.
257N/A
257N/A 7. Login to the UI at https://localhost:8443/openidmui. You can use
257N/A openidm-admin/openidm-admin for admin access or DDOE1/TestPassw0rd2 for
257N/A non-admin access. Updates to DDOE1 will be synced backed to both XML files.
257N/A
257N/A 8. Now make the LDAP xml file unavailable by renaming it so it is unreadable.
257N/A You may need to have root or sudo access to do this:
257N/A $ mv /path/to/openidm/samples/sample5b/data/xml_LDAP_Data.xml /path/to/openidm/samples/sample5b/data/xml_LDAP_Data.xml.bak
257N/A
257N/A 9. Perform an update to the DDOE1 user. It will be updated in managed/user,
257N/A the synchronization to AD will be successful, but the synchronization to
257N/A LDAP should fail. The compensate.js script will be invoked and will
257N/A attempt to revert the change by performing another update to DDOE1 in
257N/A managed/user, which will, in turn, perform the sync to AD and LDAP.
257N/A On the second time through, the sync will again fail to LDAP, which will
257N/A trigger the compensate.js again. The script this time will recognize
257N/A that the change was originally called from compensation and will abort.
257N/A The original sync error on the first update will be thrown from the
257N/A script and the UI should display an error.
257N/A
257N/A Note that if you are making these updates from the UI, the UI screen does
257N/A not refresh after the failure. It will still show the "pending update"
257N/A that has not taken effect. Go back to the Users tab and start over and
257N/A you will see the old managed/user data has been restored. View the
257N/A xml_AD_Data.xml file and you will see that DDOE1 has also been reverted
257N/A to its condition prior to update.
257N/A
257N/A 10. If you have configured the recon email summary in steps 1 and 2, you
257N/A should have received an email that lists the details for the reconciliation.
257N/A