README revision 5f22ff8ce7baf0b39668468cc854eec3eb946003
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
-------------------
This sample demonstrates how to use Scripted REST to connect to OpenDJs REST API. This sample enables the basic create,
read, update, and delete (CRUD) operations for groups and users. This sample requires a fresh install of OpenIDM and
--rootUserPassword password --adminConnectorPort 4444 --baseDN dc=com --acceptLicense --addBaseEntry \
$ opendj/bin/dsconfig create-replication-server --hostname localhost --port 4444 --bindDN "cn=Directory Manager" \
$ opendj/bin/dsconfig create-replication-domain --hostname localhost --port 4444 --bindDN "cn=Directory Manager" \
--set base-dn:dc=example,dc=com --set replication-server:localhost:8989 --set server-id:3 --type generic \
$ opendj/bin/dsconfig set-log-publisher-prop --hostname localhost --port 4444 --bindDN "cn=Directory Manager" \
--bindPassword password --publisher-name "File-Based HTTP Access Logger" --set enabled:true --no-prompt \
--trustAll
$ opendj/bin/ldapmodify --bindDN "cn=Directory Manager" --bindPassword password --hostname localhost \
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
--data '{
"_id" : "group1"
}' \
http://localhost:8080/openidm/system/scriptedrest/group?_action=create
{
"_id": "group1",
"cn": "group1",
"members": null,
"lastModified": null,
"created": "2014-09-24T17:34:27Z",
"displayName": "group2"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
--data '{
"givenName" : "User",
"familyName" : "Smith",
"emailAddress" : "user@example.com",
"telephoneNumber" : "444-444-4444",
"password" : "TestPassw0rd",
"displayName" : "User.Smith",
"uid" : "user"
}' \
http://localhost:8080/openidm/system/scriptedrest/account?_action=create
{
"_id": "user",
"displayName": "User.Smith",
"uid": "user",
"groups": null,
"familyName": "Smith",
"emailAddress": "user@example.com",
"givenName": "User",
"created": "2014-09-24T17:35:46Z",
"telephoneNumber": "444-444-4444"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
--data '{
"givenName" : "User",
"familyName" : "Smith",
"emailAddress" : "user@example.com",
"telephoneNumber" : "555-555-5555",
"password" : "TestPassw0rd",
"displayName" : "User.Smith",
"uid" : "user"
}' \
{
"_id": "user",
"displayName": "User.Smith",
"uid": "user",
"groups": null,
"familyName": "Smith",
"emailAddress": "user@example.com",
"givenName": "User",
"created": "2014-09-24T17:35:46Z",
"telephoneNumber": "555-555-5555"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
--data '{
"_id" : "group1",
"members" : [{"_id" : "user"}]
}' \
{
"_id": "group1",
"cn": "group1",
"members": [
{
"displayName": "User.Smith",
"_id": "user"
}
],
"lastModified": "2014-09-24T17:31:42Z",
"created": "2014-09-24T17:27:37Z",
"displayName": "group1"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
{
"_id": "user",
"displayName": "User.Smith",
"uid": "user",
"groups": [
{
"_id": "group1"
}
],
"familyName": "Smith",
"emailAddress": "user@example.com",
"givenName": "User",
"created": "2014-09-24T17:31:04Z",
"telephoneNumber": "555-555-5555"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
{
"_id": "group1",
"cn": "group1",
"members": [
{
"displayName": "User.Smith",
"_id": "user"
}
],
"lastModified": "2014-09-24T17:31:42Z",
"created": "2014-09-24T17:27:37Z",
"displayName": "group1"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
{
"_id": "user"
}
--header "X-OpenIDM-Username: openidm-admin" \
--header "X-OpenIDM-Password: openidm-admin" \
{
"_id": "group1"
}