You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2025/05/22 14:26:11 UTC
(directory-site) branch master updated: Updated the user-guide
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-site.git
The following commit(s) were added to refs/heads/master by this push:
new 9778a4b1 Updated the user-guide
9778a4b1 is described below
commit 9778a4b14da9e9668d65da040b09d3cf0a4251a5
Author: Emmanuel Lécharny <em...@worteks.com>
AuthorDate: Thu May 22 16:25:40 2025 +0200
Updated the user-guide
---
source/api/user-guide/1.4-preparation-to-code.md | 4 +--
source/api/user-guide/2-basic-ldap-api-usage.md | 10 +++---
.../api/user-guide/2.1-connection-disconnection.md | 39 ++++++++++++++++------
source/api/user-guide/2.2-binding-unbinding.md | 31 +++++++++--------
4 files changed, 52 insertions(+), 32 deletions(-)
diff --git a/source/api/user-guide/1.4-preparation-to-code.md b/source/api/user-guide/1.4-preparation-to-code.md
index bf859d21..25abc6d3 100644
--- a/source/api/user-guide/1.4-preparation-to-code.md
+++ b/source/api/user-guide/1.4-preparation-to-code.md
@@ -12,7 +12,7 @@ navNextText: 2 - Basic LDAP API Usage
The **Apache Directory LDAP API** requires **Java 8** or higher.
-Secondly, you must download the **[API 1.0](https://directory.apache.org/api/downloads-1.html)** or **[API 2.0](https://directory.apache.org/api/downloads-2.html)**. This package contains the **LDAP API** plus all of its dependent jars (like _commons-lang_, _slf4j_...).
+Secondly, you must download the **[API 2.0](https://directory.apache.org/api/downloads-2.html)** or **[API 2.1](https://directory.apache.org/api/downloads-2.html)**. This package contains the **LDAP API** plus all of its dependent jars (like _commons-lang_, _slf4j_...).
If you're using **Maven**, add the following dependency on _api-all.jar_ :
@@ -20,7 +20,7 @@ If you're using **Maven**, add the following dependency on _api-all.jar_ :
<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-all</artifactId>
- <version>${ldap-api-version}</version>
+ <version>[The specific LDAP API version]</version>
</dependency>
```
diff --git a/source/api/user-guide/2-basic-ldap-api-usage.md b/source/api/user-guide/2-basic-ldap-api-usage.md
index c0e89f3e..7ad7d047 100644
--- a/source/api/user-guide/2-basic-ldap-api-usage.md
+++ b/source/api/user-guide/2-basic-ldap-api-usage.md
@@ -10,15 +10,13 @@ navNextText: 3 - Advanced LDAP API Usage
# 2 - Basic LDAP API usage (...)
-We provide three different sets of methods to send requests to the **LDAP** server:
+Each LDAP operations are requests that may get a response (except the _Abandon_ or _Unbind_ requests).
-* The first set is the simplest. Its methods don't return a response but may throw a LdapOperationException if the operation was not successful.
-* The second set is for advanced users. It works with dedicated Request and Response objects and allows fine-grained control at the LDAP protocol level.
-* The third set allows users to send asynchronous requests.
+Some request though may get more than one response, like the _Search_ operation (which may get one or more_SearchResult Entry_, _SearchResultReference_ and _SearchResultDone_).
-The first set of methods covers all basic LDAP operations: Bind, Add, Delete, Modify, Move/Rename/MoveAndRename, Compare, and Unbind operations
+Last, not least, in specific cases an _IntermediateResponse_ may be sent as a reponse to an _ExtendedRequest_ (which will receive an _ExtendedResponse_ at some point later).
-The second and third sets cover all basic LDAP operations, Extended operations, and LDAP Controls.
+We will explain some of the most used operations in this chapter.
## Contents
diff --git a/source/api/user-guide/2.1-connection-disconnection.md b/source/api/user-guide/2.1-connection-disconnection.md
index 9633a1d7..77e382c7 100644
--- a/source/api/user-guide/2.1-connection-disconnection.md
+++ b/source/api/user-guide/2.1-connection-disconnection.md
@@ -10,7 +10,7 @@ navNextText: 2.2 - Binding and unbinding
# 2.1 - Connection and disconnection
-The **LDAP** is a protocol requires users to be connected, and likely identified (authenticated), before sending requests to the server. This connection can potentially be maintained forever. What makes the **LDAP** protocol different from, say, the **HTTP** protocol is that the connections are issued explicitly. Here we'll see how it's done.
+**LDAP** is a protocol that requires users to be connected, and likely identified (authenticated), before sending requests to the server. This connection can potentially be maintained forever. What makes **LDAP** protocol different from, say, **HTTP** protocol is that connections are issued explicitly. Here we'll see how it's done.
## Opening a connection
@@ -18,19 +18,30 @@ We can open a secure or a standard connection.
### Standard connection
-We can first establish a standard connection, where the data is sent and received in clear text (encoded in ASN.1 BER, but not encrypted). This example shows how it's done:
+We can first establish a standard connection, where the data is sent and received in clear text (encoded in **ASN.1 BER**, but not encrypted). This example shows how it's done:
```Java
LdapConnection connection = new LdapNetworkConnection( "localhost", 389 );
```
-Here we created an unsafe connection locally using the 389 port. Which is quite simple to do but not safe because data is not encrypted.
+Here we created an unsafe connection locally using the 389 port, with a local server. It's quite simple to do but not safe because data are not encrypted.
### Secure connection
-Although the **LDAPS** (**LDAP** over **SSL**) is now considered as deprecated, many people still use it. The big advantage of not using **LDAPS** is that you don't need two different listening ports (one for **LDAP** -389- and another one for **LDAPS** -636- ).
+There are two ways to secure a **LDAP** connection:
-The only difference with the previous example is that we tell the connection to use **SSL**, by passing **_true_** as a third parameter (incidentally, passing **_false_** sets an unsafe connection).
+* Either by using **LDAPS**, which requires a dedicated port (by default, 636)
+* Or by sending a **StartTLS** extended request which will tell the server to secure the existing connection, keeping the defined **LDAP** port (by default, 389)
+
+Although **LDAPS** (**LDAP** over **SSL**) is considered as deprecated, many people still use it. The big advantage of not using **LDAPS** is that you don't need two different listening ports (one for **LDAP** -389- and another one for **LDAPS** -636- ). On the other hand, it's guarantee to have the communication secured, while you must **NOT** forget to send the **StartTLS** operation if you want to secure the communication if you have opened the connection using **LDAP**.
+
+We will focus on using **LDAPS** in this guide.
+
+#### Securing using LDAPS
+
+The only difference with the previous example is that we tell the connection to use **SSL**, by passing **_true_** as a third parameter (incidentally, passing **_false_** sets an unsafe connection, which is the default).
+
+Do not forget to stipulate the proper port, too!
Here is an example
@@ -40,7 +51,7 @@ Here is an example
## Maintaining the connection opened
-We keep the connection open for a limited period of time, defaulting to 30 seconds. This might be not long enough, so one can change this delay by calling the _setTimeOut()_ method :
+We keep the connection opened for a limited period of time, defaulting to 30 seconds. This might be not long enough, so one can change this delay by calling the _setTimeOut()_ method :
```Java
LdapConnection connection = new LdapNetworkConnection( "localhost", 389 );
@@ -53,7 +64,7 @@ We keep the connection open for a limited period of time, defaulting to 30 secon
## Closing the connection
-Once the connection is no longer needed (remember that holding a connection keeps the session open on the server and a socket is held open between the client and the server), then you must close it. This is done by calling the _close()_ method :
+Once the connection is no longer needed (remember that holding a connection keeps the session opened on the server and a socket is held open between the client and the server), then you must close it. This is done by calling the _close()_ method :
```Java
LdapConnection connection = new LdapNetworkConnection( "localhost", 389 );
@@ -63,7 +74,7 @@ Once the connection is no longer needed (remember that holding a connection keep
## Using a pool of connections
-Creating a connection is expensive. If that connection will be reused, or if your application needs multiple connections, you may want to consider using a _connection pool_.
+Creating a connection is expensive. If the connection will be reused, or if your application needs multiple connections, you may want to consider using a _connection pool_.
This process is slightly more complex given that there are many parameters that can be used to tune the pool. Here is an example:
@@ -97,9 +108,17 @@ This process is slightly more complex given that there are many parameters that
new DefaultPoolableLdapConnectionFactory( factory ), poolConfig ) );
```
-This creates a pool of connections that are pre-authenticated. If you don't setName and setCredentials, then the pool will contain unauthenticated connections.
+This creates a pool of connections that are pre-authenticated. If you don't use the _setName_ and _setCredentials_ methods, then the pool will contain unauthenticated connections.
+
+The _DefaultPoolableLdapConnectionFactory_ is sufficient for most of the cases.
+
+However some operations result in modifications to the connection itself. For example, when the pool is created, a bind operation will occur with the credentials supplied as part of the configuration.
+
+If you borrow a connection and perform a bind yourself, that would result in the connection being re-bound as a different user.
+
+The next time that connection gets borrowed, things are likely to break.
-The _DefaultPoolableLdapConnectionFactory_ is sufficient for many cases. However some operations result in modifications to the connection itself. For example, when the pool is created, a bind operation will occur with the credentials supplied as part of the config. If you borrow a connection and perform a bind yourself, that would result in the connection being re-bound as a different user. The next time that connection gets borrowed, things are likely to break. If you perform any [...]
+If you perform any operation that results in a modification of the connection, you should instead use _ValidatingPoolableLdapConnectionFactory_:
```Java
...
diff --git a/source/api/user-guide/2.2-binding-unbinding.md b/source/api/user-guide/2.2-binding-unbinding.md
index 3ff16867..2c63a08d 100644
--- a/source/api/user-guide/2.2-binding-unbinding.md
+++ b/source/api/user-guide/2.2-binding-unbinding.md
@@ -10,15 +10,15 @@ navNextText: 2.3 Searching
# 2.2 - Binding and unbinding
-In **LDAP**, if one wants to access the data in the base, the common way to do it is to bind to the server. However, it's important to understand that binding is a different from connecting.
+In **LDAP**, if one wants to access the server data, the common way to do it is to bind to the server. However, it's important to understand that binding is different from connecting.
Creating a connection to an **LDAP** server opens a socket between the client and the server. You must provide the address and the port in order to do this.
-The **bind** operation, on the other hand, creates a _Session_ which will hold user information for the duration of the session. This information is limited, but includes the user's credentials.
+The **bind** operation, on the other hand, creates a _LdapSession_ which will hold user's information for the duration of the session. This information are limited.
-But it's important to know that it's possible to bind anonymously, which doesn't require a user or password, and still be able to send requests to the server (although the server can forbid anonymous binds).
+But it's important to know that it's possible to _bind_ anonymously, which doesn't require a user or password, and still be able to send requests to the server (although the server can forbid anonymous binds).
-Once the user has finished interacting with the server, they can unbind, destroying the session held on the server. This operation does not close the connection, because, again _bind != connection_!
+Once the user has finished interacting with the server, they can _unbind_, destroying the session held on the server. This operation does not close the connection, because, again _bind != connection_!
## Binding
@@ -27,12 +27,13 @@ There are two possible types of binds in *LDAP*:
* **Simple**
* **SASL**
-The first one is based on a userid/password sent to the server, which verifies the credentials are valid. It's also possible to proceed with an anonymous bind explicitly.
+The first one is based on a user/password sent to the server, which verifies the credentials are valid. It's also possible to proceed with an anonymous bind explicitly.
-The second type is more complicated, and is used whenever authentication with a specific mechanism, like **DIGEST-MD5**, **Kerberos** or certificate based is required.
+The second type is more complicated, and is used whenever authentication uses a specific mechanism, like **DIGEST-MD5**, **Kerberos** or certificate based is required.
### Simple Bind
-One can issue three kinds of simple binds:
+
+One can issue three kinds of simple bind:
* _anonymous bind_
* _name/password bind_
@@ -40,7 +41,7 @@ One can issue three kinds of simple binds:
The first one is the easiest, but depending on the server's configuration, will be accepted or rejected (not all servers allow anonymous binds)
-Most of the time, the _bind_ operation will not return anything. You either get bound, or will receive an _LdapException_ if an error occurs.
+Most of the time, the _bind_ operation will not return anything but a success or an error result code. You either get bound, or will receive an _LdapException_ if an error occurs, so there is no need to proceed with the returned _BindResponse_.
Issuing an anonymous bind is simple, you neither provide a user nor a password:
@@ -51,6 +52,7 @@ Issuing an anonymous bind is simple, you neither provide a user nor a password:
connection.bind();
}
```
+
Issuing a user/password bind is slightly more complex, because those credentials must be included:
```Java
@@ -63,15 +65,14 @@ Issuing a user/password bind is slightly more complex, because those credentials
>**Note** It's important to note that the user's name is a *[Dn](6.9-dn.html)*, not a simple name like 'John Doe"
-Last, not least, there is a quite unknown feature in **LDAP** bind that allows you to issue a Bind request without providing a password. It's equivalent to an anonymous bind, except that the server can log the user's name, thus being able to trace what the user does. Servers might forbid such bind, and this will be the case if the server disallow anonymous binds.
+Last, not least, there is a quite unknown feature in **LDAP** bind that allows you to issue a _Bind request_ without providing a password. It's equivalent to an _anonymous_ bind, except that the server can log the user's name, thus being able to trace what the user does. Servers might forbid such bind, and this will be the case if the server disallow anonymous binds.
-Note that this kind of bind will be supported only if the server allows anonymous binds. It's not supported by *ApacheDS*.
+Note that this kind of bind will be supported only if the server allows anonymous binds. It's not supported by *ApacheDS* by default.
```Java
@Test
public void testSimpleBindRequest() throws Exception
{
-
connection.bind( "uid=admin,ou=system" );
}
```
@@ -190,7 +191,7 @@ This is not an issue if your authentication comes from key tables or prompts the
## Rebinding
-It's possible to issue a **Bind** on an already bound connection and the existing LDAP session will be terminated, and replaced by a new LDAP session. In any case, the connection is not dropped when doing so. Note that if the connection was encrypted, it remains encrypted.
+It's possible to issue a **Bind** on an already bound connection and the existing **LDAP** session will be terminated, and replaced by a new **LDAP** session. In any case, the connection is not dropped when doing so. Note that if the connection was encrypted, it remains encrypted.
```Java
@Test
@@ -206,7 +207,7 @@ It's possible to issue a **Bind** on an already bound connection and the existin
}
```
-If you issue a _bind_ on the same connection with some different credentials, then the existing session will be terminated on the server, and a new one will be created. All the pending requests for the initial session will be lost.
+If you issue a _bind_ on the same connection with different credentials, then the existing session will be terminated on the server, and a new one will be created. All the pending requests for the initial session will be lost.
## Unbinding
@@ -230,5 +231,7 @@ It's important to know that when you issue an **Unbind**, the connection is drop
}
```
-Last, but not least, if you close the connection, the session also terminates.
+>**Note** In this example, we have called the _unbind_ operation, which has closed the connection. How is it possible that a _bind_ operation can be applied on a closed connection? Actually, the **LDAP API** will automatically recreate a connection in this case.
+
+Last, but not least, if you close the connection, the session also terminates, without having to call _unbind_.