Using the CLI to create an organization-specific LDAP user registry
You can use the developer toolkit CLI to configure an organization-specific LDAP user registry to provide user authentication for the Developer Portal. APIs can also be secured with an LDAP user registry.
Before you begin
To configure an LDAP user registry as a resource in API Manager, the LDAP directory must be created and available to use with your API Connect ecosystem.
LDAP registries can be used to secure APIs, or for securing a Catalog to authenticate Developer Portal users.
Active Directory
, you must indicate this by using the
property "directory_type": "ad"
in the LDAP config.One of the following roles is required to configure an LDAP user registry:
- Administrator
- Owner
- Topology Administrator
- Custom role with the Settings: Manage permissions
About this task
You can create an LDAP user registry that is specific to a provider organization, or one that can be shared and available to all of the provider organizations in your API Connect environment. An organization-specific LDAP user registry can be used for onboarding and authenticating Developer Portal users in a specific provider organization. While a shared LDAP user registry can be used for authenticating Cloud Manager, API Manager, and Developer Portal users.
This topic describes how to configure an organization-specific LDAP user registry. If you want to create a shared registry, see Using the CLI to configure a shared LDAP user registry for more information.- You can also create organization-specific LDAP user registries by using the API Manager UI; for more information see Creating an LDAP user registry in API Manager.
- In addition, you can create and manage LDAP user registries by using the API Connect REST APIs; see the API Connect REST API documentation.
- If you are using the DataPower® API Gateway, LDAP group authentication is not supported.
- You can map external LDAP groups to API Connect user roles to
enable more control of user authorization by using the developer toolkit CLI. The following
instructions explain how to set the
external_group_mapping_enabled
configuration on your LDAP user registry resource. For information about how to set external role mapping on your API Connect user roles, see Configuring LDAP group mapping on Cloud Manager user roles.
You create an LDAP user registry by first defining the registry details in a configuration file. You then use a developer toolkit CLI command to create the registry, passing the configuration file as a parameter. To make the registry available to the Developer Portal, you must enable the registry in the associated Catalog. To secure APIs with an LDAP registry, you must configure security definitions. You can use the following instructions to create a writable or a read-only LDAP user registry.
For general information about authenticating with LDAP, see LDAP authentication.
Logging in to the management server CLI
apic login --server mgmt_endpoint_url --username user_id --password password --realm provider/identity_provider
--realm
parameter by entering the following command to see a list of all available
identity providers (you do not need to be logged in to use this
command):apic identity-providers:list --scope provider --server mgmt_endpoint_url --fields title,realm
For example,apic identity-providers:list --scope provider --server myserver.com --fields title,realm
total_results: 2
results:
- title: API Manager User Registry
realm: provider/default-idp-2
- title: Corporate LDAP user registry
realm: provider/corporate-ldap
The title
value should enable you to determine which identity provider to use;
you can then copy the corresponding --realm
parameter directly from the displayed
realm
value. For any identity providers that were created by your
administrator after API Connect was installed,
the names will have been determined at creation time. The default API Manager Local User Registry
for login as a member of a provider organization is default-idp-2
.For full details of the login command, see Logging in to a management server.
For more information about how to use the CLI, see Installing the toolkit, and Overview of the command-line tool.
Defining your LDAP configuration
ldap_config_file.yaml
file, as shown in the following example.
Note that the actual contents of your YAML file will vary depending on the authentication method of
your LDAP server, and this is explained in the following tables.
name: registry_name
title: "display_title"
integration_url: LDAP_integration_url
user_managed: true_or_false
user_registry_managed: false
directory_type: ad
external_group_mapping_enabled: true_or_false
case_sensitive: true_or_false
email_required: true_or_false
email_unique_if_exist: true_or_false
identity_providers:
- name: provider_name
title: provider_title
endpoint:
endpoint: "ldap_server_url_and_port"
configuration:
authentication_method: authentication_method
authenticated_bind: "true_or_false"
admin_dn: "admin_dn"
admin_password: admin_password
search_dn_base: "search_dn_base"
search_dn_scope: search_dn_scope
search_dn_filter_prefix: prefix
search_dn_filter_suffix: suffix
attribute_mapping:
dn: "distinguished_name"
cn: "common_name"
sn: "last_name"
mail: "email_address"
userPassword: "password"
The
registry properties that are common to each authentication method are described in the following
table: Property | Description |
---|---|
name |
The name of the registry. This name is used in CLI commands. |
title |
A descriptive name to display in a graphical user interface. |
integration_url |
The LDAP integration URL in your API Connect configuration.
You can determine the LDAP integration URL by using the following CLI
command:
|
user_managed |
Determines whether your user registry is writable or not. Must be set to
true for writable LDAP. You can change this setting to false if
you don't want the registry to be writable; see the Switching your LDAP registry between writable and
read-only section at the end of this topic for
details. Note that a writable LDAP user registry cannot be used to authenticate Cloud
Manager and API Manager users. |
user_registry_managed |
Must be set to false for LDAP. Determines whether API Connect manages your
user registry. Only LUR registries are managed by API Connect. |
directory |
Specify one of the of following values for the directory type:
|
external_group_mapping_enabled |
Determines whether your user registry supports LDAP group mapping. Valid values are:
false . |
case_sensitive |
Determines whether your user registry is case-sensitive. Valid values are:
Note: After at least one user has been onboarded into the registry, you cannot change this
setting.
|
email_required |
Determines whether an email address is required as part of the user onboarding process.
Valid values are:
true , the source identity provider must supply the email address as
part of the authentication process during onboarding.Note: An email address is not required by
default for onboarding to the Cloud
Manager or the API Manager, but it is required
for onboarding to the Developer Portal.
|
email_unique_if_exist |
Determines whether email addresses must be unique within the user registry. Valid values
are:
Note: Every account in the Developer Portal,
including across different user registries for the same site, must have a unique email address,
including the site Admin account.
|
identity_providers |
An array containing the details of your LDAP server, where:
|
endpoint |
The endpoint of your LDAP server, made up of the url and port, for
example:
|
tls_profile |
Optionally set the TLS Client Profile that the LDAP server requires. |
protocol_version |
Optionally set the version number for the LDAP protocol that you are using. Valid values
are:
3 if not explicitly set. |
compose_dn
- Set this format if you can compose the user LDAP Distinguished Name (DN) from the user name. For example,uid=<username>,ou=People,dc=company,dc=com
is a DN format that can be composed from the user name. If you are unsure whether Compose (DN) is the correct option, contact your LDAP administrator. If you are using an LDAP registry to secure APIs,compose_dn
is not supported with the DataPower API Gateway.compose_upn
- Set this format if your LDAP directory supports binding with User Principal Names such asjohn@acme.com
. The Microsoft Active Directory is an example of an LDAP directory that supports Compose UPN authentication. If you are unsure whether your LDAP directory supports binding with UPNs, contact your LDAP administrator.Note: The Admin Bind DN and Admin Bind Password are not used with this authentication method.search_dn
- Select this format if you cannot compose the user LDAP Distinguished Name from the user name; for example, if the base DNs of the users are different. This format might require an administrator DN and password to search for users in the LDAP directory. If your LDAP directory permits anonymous binds, you can omit the admin DN and password. If you are unsure if your LDAP directory permits anonymous binds, contact your LDAP administrator.
compose_dn
, set the following
configuration properties:Properties | Description |
---|---|
authentication_method |
compose_dn |
authenticated_bind |
The bind method. Valid values are:
"false" .
If specific permissions are necessary, select "true" . |
admin_dn |
If authenticated_bind is set to "true" , enter the
Distinguished Name (DN) of a user authorized to perform searches in the LDAP directory. For
example:
|
admin_password |
If authenticated_bind is set to "true" , enter the user
password for the admin_dn . |
search_dn_base |
Optionally set a base DN, for example:
|
bind_prefix |
Set the prefix to the DN, for example:
|
bind_suffix |
Set the suffix to the DN, for example:
|
attribute_mapping |
If user_managed is set to true ,
provide the mapping of your source LDAP attribute names to the target API Connect values. This
mapping is configured as a name/value pair, specified as
follows: Where:
username , first_name ,
last_name , email , and password .The following
extract shows an example of an attribute
mapping:
|
compose_upn
, set the following
configuration properties:Properties | Description |
---|---|
authentication_method |
compose_upn |
authenticated_bind |
The bind method. Valid values are:
"false" .
If specific permissions are necessary, select "true" . |
admin_dn |
If authenticated_bind is set to "true" , enter the
Distinguished Name (DN) of a user authorized to perform searches in the LDAP directory. For
example:
|
admin_password |
If authenticated_bind is set to "true" , enter the user
password for the admin_dn . |
bind_suffix |
Enter the domain part of the user principal name. For
example:
|
attribute_mapping |
If user_managed is set to true ,
provide the mapping of your source LDAP attribute names to the target API Connect values. This
mapping is configured as a name/value pair, specified as
follows: Where:
username , first_name ,
last_name , email , and password .The following
extract shows an example of an attribute
mapping:
|
search_dn
, set the following
configuration properties:Property | Description |
---|---|
authentication_method |
search_dn |
authenticated_bind |
The bind method. Valid values are:
"false" .
If specific permissions are necessary, select "true" . |
admin_dn |
If authenticated_bind is set to "true" , enter the
Distinguished Name (DN) of a user authorized to perform searches in the LDAP directory. For
example:
|
admin_password |
If authenticated_bind is set to "true" , enter the user
password for the admin_dn . |
search_dn_base |
Optionally set a base DN, for example:
|
search_dn_scope |
Optionally set the search DN scope. The scope determines which part of the directory
information tree is examined. Possible values are:
|
search_dn_filter_prefix |
Set the prefix to the DN, for example:
|
search_dn_filter_suffix |
Set the suffix to the DN, for example:
|
attribute_mapping |
If user_managed is set to true ,
provide the mapping of your source LDAP attribute names to the target API Connect values. This
mapping is configured as a name/value pair, specified as
follows: Where:
username , first_name ,
last_name , email , and password .The following
extract shows an example of an attribute
mapping:
|
Save your ldap_config_file.yaml
so it can be accessed by the
user-registries:create
command in the following section. See the Example section for an example
configuration file.
Creating your LDAP user registry
apic user-registries:create --server mgmt_endpoint_url --org organization_name ldap_config_file.yaml
where:- mgmt_endpoint_url is the platform API endpoint URL.
- organization_name is the value of the
name
property of your provider organization. - ldap_config_file is the name of the YAML file that defines the configuration of your LDAP user registry.
registry_name registry_url
The
registry_name is derived from the name
property in the
configuration YAML file. The registry_url is the URL with which the registry
resource can be accessed.Your LDAP user registry is now created; see the following section for instructions on how to make the registry available in the Developer Portal.
Configuring your LDAP registry in a Catalog
Switching your LDAP registry between writable and read-only
user_managed
property in the registry configuration. Complete the
following steps.- Determine the name or ID of the LDAP user registry that you want to update, by running the
following command (or you can use the summary from the registry
creation):
The command returns a list of all the user registries for that organization, shown by name followed by their registry URL. The registry ID is located at the end of the URL, for exampleapic user-registries:list --server mgmt_endpoint_url --org organization_name
https://company.com/api/user-registries/x-x-x-x-x/registry_id
. - Enter the following command (the terminating hyphen character means that the command takes input
from the command
line):
whereapic user-registries:update --server mgmt_endpoint_url --org organization_name registry_name_or_id -
registry_name_or_id
is the name or ID of the LDAP user registry that you want to update (as determined in the previous step). The command returns:Reading USER_REGISTRY_FILE arg from stdin
- Enter the following data, followed by a new
line:
whereuser_managed: true_or_false
true
makes the registry writable, andfalse
makes the registry read-only. - Press
CTRL D
to terminate the input.
attribute_mapping
configuration, as described in the previous registry property
tables.Using an LDAP user registry to secure APIs
- To use for basic authentication in the security definition for an API, see Creating a basic authentication security definition.
- To use for authentication in the User Security configuration for a native OAuth provider, see Configuring user security for a native OAuth provider.
For details of all the apic user-registries
and apic
configured-catalog-user-registries
commands, see apic
user-registries and apic configured-catalog-user-registries.
Example
name: sdn-ldap
title: "SDN LDAP User Registry"
integration_url: https://mycompany.com/api/cloud/integrations/user-registry/xxx-xxx-xxx
user_managed: true
user_registry_managed: false
directory_type: standard
case_sensitive: false
identity_providers:
- name: ldap
title: "SDN LDAP Identity Provider"
endpoint:
endpoint: "ldap://mycompany.com:389"
configuration:
authentication_method: search_dn
authenticated_bind: "true"
admin_dn: "cn=admin,dc=company,dc=com"
admin_password: xxxx
search_dn_base: "dc=company,dc=com"
search_dn_scope: sub
search_dn_filter_prefix: (uid=
search_dn_filter_suffix: )
attribute_mapping:
dn: "uid=[username],ou=users,dc=company,dc=com"
cn: "[first_name] [last_name]"
sn: "[last_name]"
mail: "[email]"
userPassword: "[password]"