Lightweight Directory Access Protocol (LDAP) Configuration#
The Janssen Server provides multiple configuration tools to perform these tasks.
Use the command line to perform actions from the terminal. Learn how to use Jans CLI here or jump straight to the Using Command Line
LDAP Configuration is not possible in Text-based UI.
Use REST API for programmatic access or invoke via tools like CURL or Postman. Learn how to use Janssen Server Config API here or Jump straight to the Using Configuration REST API
Using Command Line#
In the Janssen Server, you can configure the LDAP backend using the
command Line. To get the details of Janssen command line operations relevant to
LDAP configuration, check the operations under the DatabaseLdapConfiguration
task using the command below:
/opt/jans/jans-cli/config-cli.py --info DatabaseLdapConfiguration
It will list the relevant operations as listed below:
Operation ID: get-config-database-ldap
Description: Gets list of existing LDAP configurations.
Operation ID: put-config-database-ldap
Description: Updates LDAP configuration
Schema: GluuLdapConfiguration
Operation ID: post-config-database-ldap
Description: Adds a new LDAP configuration
Schema: GluuLdapConfiguration
Operation ID: get-config-database-ldap-by-name
Description: Gets an LDAP configuration by name.
Parameters:
name: Name of LDAP configuration [string]
Operation ID: delete-config-database-ldap-by-name
Description: Deletes an LDAP configuration
Parameters:
name: No description is provided for this parameter [string]
Operation ID: patch-config-database-ldap-by-name
Description: Patches a LDAP configuration by name
Parameters:
name: Name of LDAP configuration [string]
Schema: Array of JsonPatch
Operation ID: post-config-database-ldap-test
Description: Tests an LDAP configuration
Schema: GluuLdapConfiguration
To get sample schema type /opt/jans/jans-cli/config-cli.py --schema <schema>,
for example /opt/jans/jans-cli/config-cli.py --schema GluuLdapConfiguration
Get Existing LDAP Configurations#
To get information about existing LDAP configurations, run the following command:
/opt/jans/jans-cli/config-cli.py --operation-id get-config-database-ldap
Sample Output | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Add a new LDAP Configuration#
To add a new a LDAP configuration, use the post-config-database-ldap
operation id. As shown in the output for
--info
command. The post-config-database-ldap
operation
requires data to be sent according to GluuLdapConfiguration
schema.
To see the schema, use the command below:
/opt/jans/jans-cli/config-cli.py --schema GluuLdapConfiguration
The Janssen Server also provides an example of data that adheres to the above schema. To fetch the example, use the command below.
/opt/jans/jans-cli/config-cli.py --schema-sample GluuLdapConfiguration
Using the schema and the example above, we have added below data to the
file /tmp/ldap.json
.
Input | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
/opt/jans/jans-cli/config-cli.py --operation-id post-config-database-ldap\
--data /tmp/ldap.json
Please note that configId
should be a unique identifier for each configuration.
Update LDAP Configuration#
To update an existing LDAP configuration, we can use put-config-database-ldap
operation id. As shown in the output for --info
command,
the put-config-database-ldap
operation requires data to be sent according to
GluuLdapConfiguration
schema.
For example, let's say we are going to change the maxConnections
from 1000
to 100
in the above test_ldap
configuration. So let's update this value
in the /tmp/ldap.json
file that we created earlier and use the command
below to update the configuration on the server:
/opt/jans/jans-cli/config-cli.py --operation-id put-config-database-ldap \
--data /tmp/ldap.json
Sample Output | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Get LDAP Configuration by its name#
When retrieving LDAP configuration by name
, the value of name
parameter
in the query is matched with the configId
of the LDAP configuration.
Use the command below to retrieve LDAP configuration with configId
as
test_ldap
.
/opt/jans/jans-cli/config-cli.py --operation-id get-config-database-ldap-by-name\
--url-suffix name:test_ldap
Here the name
parameter is matched with the configId
of the configuration.
Sample Output | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Delete LDAP Configurations#
To delete any existing LDAP Database configuration, use the command as below.
/opt/jans/jans-cli/config-cli.py --operation-id delete-config-database-ldap-by-name \
--url-suffix name:test_ldap
It will delete LDAP configuration where configId
matches with the name
.
Patch LDAP Configurations#
To patch a single configuration element in a given LDAP configuration
by using its name, use the patch-config-database-ldap-by-name
operation. For
example, changing the level
or test_ldap
configuration.
Operation ID: patch-config-database-ldap-by-name
Description: Patches a LDAP configuration by name
Parameters:
name: Name of LDAP configuration [string]
Schema: Array of JsonPatch
The patch-config-database-ldap-by-name
uses the
JSON Patch
schema to describe the configuration change. Refer
here
to know more about schema.
Create a patch file with the contents as below to update the level
of a LDAP
configuration.
[
{
"op": "replace",
"path": "level",
"value": "100"
}
]
Use the patch file above to update the configuration of test_ldap
LDAP
configuration using the command below:
/opt/jans/jans-cli/config-cli.py \
--operation-id patch-config-database-ldap-by-name \
--url-suffix name:test_ldap --data /tmp/patch.json
It will update the configuration and show the updated result as below.
Sample Output | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Using Configuration REST API#
Janssen Server Configuration REST API exposes relevant endpoints for managing and configuring the Lightweight Directory Access Protocol. Endpoint details are published in the Swagger document.
Created: 2021-06-04