Retrieve attribute from directory server

Overview

The API Gateway can leverage an existing directory server by querying it for user profile data. The Retrieve From Directory Server filter can lookup a user and retrieve that user's attributes represented as a list of search results. Each element of the list represents a list of multi-valued attributes returned from the directory server.

General settings

Configure the following field:

Name:

Enter an appropriate name for this filter.

Database settings

Configure the following fields on the Database tab:

LDAP Directory:

The API Gateway queries the selected Lightweight Directory Access Protocol (LDAP) directory for user attributes. An LDAP connection is retrieved from a pool of connections at runtime. Click the browse button to select the LDAP directory to query. To use an existing LDAP directory, (for example, Sample Active Directory Connection), select it in the tree. To add an LDAP directory, right-click the LDAP Connections tree node, and select Add an LDAP Connection. Alternatively, you can add LDAP connections under the External Connections node in the Policy Studio tree view. For more details on how to configure LDAP connections, see Configuring LDAP Directories.

The Retrieve Unique User Identity section enables you to select the user whose profile the API Gateway looks up in the directory server. The user ID can be taken from a message attribute or looked up from an LDAP directory.

From Selector Expression:

Select this option if the user ID is stored in a message attribute, and specify the selector expression used to obtain its value at runtime (for example, ${authentication.subject.id}). A user's credentials are stored in the authentication.subject.id message attribute after authenticating to the API Gateway, so this is the most likely attribute to enter in this field. Typically, this contains the Distinguished Name (DName) or user name of the authenticated user. The name extracted from the specified message attribute is used to query the directory server. For more details on selector expressions, see Selecting configuration values at runtime.

From LDAP Search:

In cases where you have not already obtained the user's identity and the authentication.subject.id attribute has not been prepopulated by a prior authentication filter, you must configure the API Gateway to retrieve the user's identity from an LDAP search. Click the Configure Directory Search button to configure the search criteria to use to retrieve the user's unique DName from the LDAP repository.

The Retrieve Attributes section instructs the API Gateway to search the LDAP tree to locate a specific user profile. When the appropriate profile is retrieved, the API Gateway extracts the specified user attributes.

Base Criteria:

You can specify where the API Gateway should begin searching the LDAP directory using a selector. The selector represents the value of a message attribute that is expanded at runtime. The two most likely message attributes to be used here are the authenticated user's ID and Distinguished Name. Select one of the predefined selectors from the list:

  • ${authentication.subject.id}
  • ${authentication.subject.dname}

Alternatively, you can enter a selector representing other message attributes using the same syntax. For more details on selectors, see Selecting configuration values at runtime.

Search Filter:

This is the name given by the particular LDAP directory to the User class. This depends on the type of LDAP directory configured. You can also use a selector to represent the value of a message attribute. For example, you can use the user.role attribute to store the user class. The syntax for using the selector representing this attribute is as follows:

(objectclass=${user.role})

Search Scope:

If the API Gateway retrieves a user profile node from the LDAP tree, the option selected here dictates the level that the API Gateway searches the node to. The available options are:

  • Object level
  • One level
  • Sub-tree

Unique Result:

Select this option to force the API Gateway to retrieve a unique user profile from the LDAP directory. This is useful in cases where the LDAP search has returned several profiles.

Attribute Name:

The Attribute Name table lists the attributes the API Gateway retrieves from the user profile. If no attributes are listed, the API Gateway extracts all user attributes. In both cases, retrieved attributes are set to the attribute.lookup.list message attribute. Click Add to add the name of an attribute to extract from the returned user profile. Enter the attribute name to extract from the profile in the Attribute Name field of the Attribute Lookup dialog.

[Important] Important

  • If the search returns results for more that one user, and the Unique Result option is enabled, an error is generated. If this option is not enabled, all attributes are merged.

  • If an attribute is configured that does not exist in the repository, no error is generated.

  • If no attributes are configured, all attributes present for the user are retrieved.

Advanced settings

Configure the following fields on the Advanced tab:

Enable legacy attribute naming for retrieved attributes:

Specifies whether to enable legacy naming of retrieved message attributes. This field is not selected by default. Prior to version 7.1, retrieved attributes were stored in message attributes in the following format:

user.<retrieved_attribute_name>

For example, ${user.email}, ${user.role}, and so on. If the retrieved attribute was multi-valued, you would access the values using ${user.email.1} or ${user.email.2}, and so on. In version 7.1 and later, by default, you can query for multi-valued retrieved attributes using an array syntax (for example, ${user.email[0]}, or ${user.email[1]}, and so on). Select this setting to use the legacy format for attribute naming instead.

Example of output attribute format with legacy attribute naming

The following table shows the output attribute format when legacy attribute naming is selected:

Prefix for message attribute name (optional) Output attribute format (when attribute name is memberOf)
user (default)
  • attribute.lookup.list: Map of retrieved attributes

  • user.memberOf: When retrieves only a single value for the given attribute

  • user.memberOf.* (for example, user.memberOf.1, user.memberOf.2, and so on): When retrieves multiple values for the given attribute

  • ${user.memberOf}: Example selector

None
  • attribute.lookup.list: Map of retrieved attributes

  • memberOf: When retrieves only a single value for the given attribute

  • memberOf.* (for example, memberOf.1, memberOf.2, and so on): When retrieves multiple values for the given attribute

  • ${user.memberOf}: Example selector


Example of output attribute format without legacy attribute naming

The following table shows the output attribute format when legacy attribute naming is not selected:

Prefix for message attribute name (mandatory) Output attribute format (when attribute name is user.memberOf)
user (default)
  • user: List of search results, where each element of the list corresponds to search results (pairs of attribute names and values)

  • Example selector: ${user[0].memberOf[0]}


Prefix for message attribute:

You can specify an optional prefix for message attribute names. The default prefix is user. For more details, see Enable legacy attribute naming for retrieved attributes.