DS 7.1.8

Read

Examples in this documentation depend on features activated in the ds-evaluation setup profile.

Read a Resource

Perform an HTTP GET:

$ curl \
 --request GET \
 --cacert ca-cert.pem \
 --user kvaughan:bribery \
 --silent \
 "https://localhost:8443/api/users/newuser?_prettyPrint=true"

{
  "_id" : "newuser",
  "_rev" : "<revision>",
  "_schema" : "frapi:opendj:rest2ldap:user:1.0",
  "_meta" : {
    "created" : "<datestamp>"
  },
  "userName" : "newuser@example.com",
  "displayName" : [ "New User" ],
  "name" : {
    "givenName" : "User",
    "familyName" : "New"
  },
  "contactInformation" : {
    "telephoneNumber" : "+1 408 555 1212",
    "emailAddress" : "newuser@example.com"
  },
  "manager" : {
    "_id" : "kvaughan",
    "_rev": "<revision>"
  }
}

Referenced Resource Fields

Notice in the preceding example that the operation returns only the manager’s _id and _rev fields. The fields returned depend on how the reference is configured in the REST to LDAP mapping.

To return additional fields from resources referenced with a resource path in the REST to LDAP mapping, explicitly specify the field names:

$ curl \
 --request GET \
 --cacert ca-cert.pem \
 --user kvaughan:bribery \
 --silent \
 "https://localhost:8443/api/users/newuser?_fields=/displayName,/manager/displayName&_prettyPrint=true"

{
  "_id" : "newuser",
  "_rev" : "<revision>",
  "displayName" : [ "New User" ],
  "manager" : {
    "_id" : "kvaughan",
    "displayName" : [ "Kirsten Vaughan" ],
    "_rev" : "<revision>"
  }
}

To return all configured fields for the resource and the manager, use _fields=/,/manager. This returns all fields of the referenced manager resource that are configured for the REST to LDAP mapping.

Reverse References

When you read a manager’s entry, the "reverseReference" field in the mapping returns the list of users reporting to the manager when the reverse reference field is explicitly requested.

The search is not indexed by default, so the directory superuser makes the request:

$ curl \
 --request GET \
 --cacert ca-cert.pem \
 --user admin:password \
 --silent \
 "https://localhost:8443/api/users/kvaughan?_fields=/reports/displayName&_prettyPrint=true"

{
  "_id" : "kvaughan",
  "_rev" : "<revision>",
  "reports" : [ {
    "_id" : "ashelton",
    "displayName" : [ "Alexander Shelton" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "btalbot",
    "displayName" : [ "Brad Talbot" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "dakers",
    "displayName" : [ "David Akers" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "dsmith",
    "displayName" : [ "Daniel Smith" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "eward",
    "displayName" : [ "Eric Ward" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "gjensen",
    "displayName" : [ "Gern Jensen" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "hmiller",
    "displayName" : [ "Harry Miller" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "jburrell",
    "displayName" : [ "James Burrell" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "jcampai2",
    "displayName" : [ "Jeffrey Campaigne" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "jfalena",
    "displayName" : [ "John Falena" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "jvaughan",
    "displayName" : [ "Jeff Vaughan" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "kcarter",
    "displayName" : [ "Karen Carter" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "mreuter",
    "displayName" : [ "Matthew Reuter" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "newuser",
    "displayName" : [ "New User" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "pworrell",
    "displayName" : [ "Pete Worrell" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "rbannist",
    "displayName" : [ "Richard Bannister" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "rdaugherty",
    "displayName" : [ "Robert Daugherty" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "rschneid",
    "displayName" : [ "Rachel Schneider" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "striplet",
    "displayName" : [ "Stephen Triplett" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "tclow",
    "displayName" : [ "Torrey Clow" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "tmason",
    "displayName" : [ "Torrey Mason" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "tschmith",
    "displayName" : [ "Tobias Schmith" ],
    "_rev" : "<revision>"
  }, {
    "_id" : "tward",
    "displayName" : [ "Tobias Ward" ],
    "_rev" : "<revision>"
  } ]
}

Notice that the example explicitly requests reports with the _fields query parameter.

Copyright © 2010-2024 ForgeRock, all rights reserved.