Skip to content

Commit

Permalink
Document the LDAPError fields
Browse files Browse the repository at this point in the history
Also, correct the note on COMPARE_FALSE and COMPARE_TRUE

https://github.com/python-ldap/python-ldap/pull/355
  • Loading branch information
Petr Viktorin authored and GitHub committed Jun 18, 2020
1 parent d45ad6a commit 578b0b7
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions Doc/reference/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -462,26 +462,27 @@ The module defines the following exceptions:
are instead turned into exceptions, raised as soon an the error condition
is detected.

The exceptions are accompanied by a dictionary possibly
containing an string value for the key :py:const:`desc`
(giving an English description of the error class)
and/or a string value for the key :py:const:`info`
(giving a string containing more information that the server may have sent).

A third possible field of this dictionary is :py:const:`matched` and
is set to a truncated form of the name provided or alias dereferenced
for the lowest entry (object or alias) that was matched.

The field :py:const:`msgid` is set in the dictionary where the
exception can be associated with an asynchronous request.
This can be used in asynchronous code where :py:meth:`result()` raises the
result of an operation as an exception. For example, this is the case for
:py:meth:`compare()`, always raises the boolean result as an exception
(:py:exc:`COMPARE_TRUE` or :py:exc:`COMPARE_FALSE`).

Most exceptions from protocol results also carry the :py:attr:`errnum`
attribute.

The exceptions are accompanied by a dictionary with additional information.
All fields are optional and more fields may be added in the future.
Currently, ``python-ldap`` may set the following fields:

* ``'result'``: a numeric code of the error class.
* ``'desc'``: string giving a description of the error class, as provided
by calling OpenLDAP's ``ldap_err2string`` on the ``result``.
* ``'info'``: string containing more information that the server may
have sent. The value is server-specific: for example, the OpenLDAP server
may send different info messages than Active Directory or 389-DS.
* ``'matched'``: truncated form of the name provided or alias.
dereferenced for the lowest entry (object or alias) that was matched.
* ``'msgid'``: ID of the matching asynchronous request.
This can be used in asynchronous code where :py:meth:`result()` raises the
result of an operation as an exception. For example, this is the case for
:py:meth:`~LDAPObject.compare()`, always raises the boolean result as an
exception (:py:exc:`COMPARE_TRUE` or :py:exc:`COMPARE_FALSE`).
* ``'ctrls'``: list of :py:class:`ldap.controls.LDAPControl` instances
attached to the error.
* ``'errno'``: the C ``errno``, usually set by system calls or ``libc``
rather than the LDAP libraries.

.. py:exception:: ADMINLIMIT_EXCEEDED
Expand Down Expand Up @@ -515,14 +516,14 @@ The module defines the following exceptions:
.. py:exception:: COMPARE_FALSE
A compare operation returned false.
(This exception should never be seen because :py:meth:`compare()` returns
a boolean result.)
(This exception should only be seen asynchronous operations, because
:py:meth:`~LDAPObject.compare_s()` returns a boolean result.)

.. py:exception:: COMPARE_TRUE
A compare operation returned true.
(This exception should never be seen because :py:meth:`compare()` returns
a boolean result.)
(This exception should only be seen asynchronous operations, because
:py:meth:`~LDAPObject.compare_s()` returns a boolean result.)

.. py:exception:: CONFIDENTIALITY_REQUIRED
Expand Down

0 comments on commit 578b0b7

Please sign in to comment.