README revision baf15352a4774619a416d0c0b567ed834d349513
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquernaSample 3 - Scripted SQL
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna-----------------------
55b585a80949b1740ebf8d94ad154b2a4c3a8a81ndCopyright (c) 2012 ForgeRock AS
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquernaThis work is licensed under a Creative Commons Attribution-
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquernaNonCommercial-NoDerivs 3.0 Unported License. See
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquernaThis sample demonstrates an example configuration for a scripted SQL
7add1372edb1ee95a2c4d1314df4c7567bda7c62jimconnector, a connector that communicates with a database through configurable
7add1372edb1ee95a2c4d1314df4c7567bda7c62jimSQL scripts. This example requires a fresh installation of OpenIDM.
7add1372edb1ee95a2c4d1314df4c7567bda7c62jimFor documentation pertaining to this example see:
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquernahttp://openidm.forgerock.org/doc/install-guide/index.html#more-sample3
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantzTo try the example, follow these steps.
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim 1. Copy the MySQL Connector/J .jar to the OpenIDM bundle/ directory.
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim $ cp mysql-connector-java-5.1.18-bin.jar /path/to/openidm/bundle/
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim 3. Set up MySQL to listen on localhost:3306, connecting as root:password.
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd 4. Import the sample data definition language file into MySQL.
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna $ ./bin/mysql -u root -p < /path/to/openidm/samples/sample3/data/sample_HR_DB.mysql
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna Enter password:
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna $ ./bin/mysql -u root -p
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna Enter password:
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna mysql> use HRDB;
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna mysql> select * from Users;
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna +----+--------+----------+-----------+----------+---------------+---------------------------+--------------+---------------------+
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim | id | uid | password | firstname | lastname | fullname | email | organization | timestamp |
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim +----+--------+----------+-----------+----------+---------------+---------------------------+--------------+---------------------+
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim | 1 | bob | password | Bob | Fleming | Bob Fleming | Bob.Fleming@example.com | HR | 2012-02-20 12:16:44 |
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim | 2 | rowley | password | Rowley | Birkin | Rowley Birkin | Rowley.Birkin@example.com | SALES | 2012-02-20 12:16:44 |
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna | 3 | louis | password | Louis | Balfour | Louis Balfour | Louis.Balfour@example.com | SALES | 2012-02-20 12:16:44 |
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim | 4 | john | password | John | Smith | John Smith | John.Smith@example.com | SUPPORT | 2012-02-20 12:16:44 |
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna | 5 | jdoe | password | John | Doe | John Doe | John.Does@example.com | ENG | 2012-02-20 12:16:44 |
55b585a80949b1740ebf8d94ad154b2a4c3a8a81nd +----+--------+----------+-----------+----------+---------------+---------------------------+--------------+---------------------+
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 5 rows in set (0.01 sec)
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna mysql> quit
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim 5. Start OpenIDM with the configuration for sample 3.
5c3c22e3324f26848c1782e711c24faf28136012jerenkrantz $ /path/to/openidm/startup.sh -p samples/sample3
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim 6. Run reconciliation:
9bcfc3697a91b5215893a7d0206865b13fc72148nd $ curl --header "Content-type: application/json" --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --request POST "http://localhost:8080/openidm/recon?_action=recon&mapping=systemHrdb_managedUser"
5383fa753e1bcd3a04ec34ba9810d671302380f2colm 7. Retrieve the list of users from OpenIDM's internal repository:
1acae7fb634ac2b01682507175e072b168995e0dcolm $ curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --request GET "http://localhost:8080/openidm/managed/user/?_queryId=query-all-ids"
1acae7fb634ac2b01682507175e072b168995e0dcolm "query-time-ms": 0,
5383fa753e1bcd3a04ec34ba9810d671302380f2colm "result": [
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim "_id": "9d1a92bf-aa88-4b48-b607-ec6d95e7b178",
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim "_rev": "0"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim "_id": "d781ba76-33ba-4581-8cda-8ed9c6d4903d",
b09705acacab4c960c608c71377aa3ec2bf9e8a1colm "_rev": "0"
b09705acacab4c960c608c71377aa3ec2bf9e8a1colm "_id": "40b7ca4f-f112-4878-ae6b-6aa97503fac6",
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna "_rev": "0"
7add1372edb1ee95a2c4d1314df4c7567bda7c62jim "_id": "3afb15e5-8713-4ba4-a464-fa9c5f952bff",
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna "_rev": "0"
6b797d6bd26bbf8589eb0e2b6cfa2fa808f456b1pquerna "_id": "5474ff66-31af-4097-b1fb-a394f9a60d95",
f9616f83476fe7a18173b677f237126e6301e18fjorton "_rev": "0"
20189240503ef2c8f5dc6e2248b57faab4b23b5and "conversion-time-ms": 0
8bb7126c063c34d63966733988411f72dfcb2294maczniak In your terminal the response appears all on one line.
8bb7126c063c34d63966733988411f72dfcb2294maczniak 8. Retrieve an individual user, using an ID value from the previous GET:
8bb7126c063c34d63966733988411f72dfcb2294maczniak $ curl --header "X-OpenIDM-Username: openidm-admin" --header "X-OpenIDM-Password: openidm-admin" --request GET "http://localhost:8080/openidm/managed/user/5474ff66-31af-4097-b1fb-a394f9a60d95"
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna "familyName": "Doe",
f9616f83476fe7a18173b677f237126e6301e18fjorton "userName": "jdoe",
f9616f83476fe7a18173b677f237126e6301e18fjorton "givenName": "John",
1acae7fb634ac2b01682507175e072b168995e0dcolm "_id": "5474ff66-31af-4097-b1fb-a394f9a60d95",
1acae7fb634ac2b01682507175e072b168995e0dcolm "_rev": "0",
f9616f83476fe7a18173b677f237126e6301e18fjorton "John.Does@example.com"
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna Again, in your terminal the response appears all on one line.