tldap package¶
Subpackages¶
- tldap.backend package
- Submodules
- tldap.backend.base module
LdapBase
LdapBase.add()
LdapBase.check_password()
LdapBase.close()
LdapBase.commit()
LdapBase.delete()
LdapBase.enter_transaction_management()
LdapBase.is_dirty()
LdapBase.is_managed()
LdapBase.leave_transaction_management()
LdapBase.modify()
LdapBase.modify_no_rollback()
LdapBase.rename()
LdapBase.reset()
LdapBase.rollback()
LdapBase.search()
LdapBase.set_connection_class()
- tldap.backend.fake_transactions module
LDAPwrapper
LDAPwrapper.add()
LDAPwrapper.commit()
LDAPwrapper.delete()
LDAPwrapper.enter_transaction_management()
LDAPwrapper.fail()
LDAPwrapper.is_dirty()
LDAPwrapper.is_managed()
LDAPwrapper.leave_transaction_management()
LDAPwrapper.modify()
LDAPwrapper.modify_no_rollback()
LDAPwrapper.rename()
LDAPwrapper.reset()
LDAPwrapper.rollback()
NoSuchObject
raise_testfailure()
- tldap.backend.no_transactions module
LDAPwrapper
LDAPwrapper.add()
LDAPwrapper.commit()
LDAPwrapper.delete()
LDAPwrapper.enter_transaction_management()
LDAPwrapper.is_dirty()
LDAPwrapper.is_managed()
LDAPwrapper.leave_transaction_management()
LDAPwrapper.modify()
LDAPwrapper.modify_no_rollback()
LDAPwrapper.rename()
LDAPwrapper.reset()
LDAPwrapper.rollback()
- Module contents
- tldap.database package
- Submodules
- tldap.database.helpers module
add_group_member()
get_fields_account()
get_fields_common()
get_fields_group()
get_fields_password_object()
get_fields_person()
get_fields_pwdpolicy()
get_fields_shadow()
get_fields_shibboleth()
load_account()
load_group()
load_password_object()
load_person()
load_pwdpolicy()
load_shadow()
load_shibboleth()
rdn_to_dn()
remove_group_member()
save_account()
save_group()
save_password_object()
save_person()
save_pwdpolicy()
save_shadow()
save_shibboleth()
set_object_class()
- Module contents
- tldap.django package
- tldap.test package
- Submodules
- tldap.test.slapd module
Slapd
Slapd.PATH_LDAPADD
Slapd.PATH_LDAPSEARCH
Slapd.PATH_SCHEMA_DIR
Slapd.PATH_SLAPD
Slapd.PATH_SLAP_TEST
Slapd.TEST_UTILS_DIR
Slapd.get_address()
Slapd.get_dn_suffix()
Slapd.get_root_dn()
Slapd.get_root_password()
Slapd.get_url()
Slapd.ldap_add()
Slapd.ldap_search()
Slapd.restart()
Slapd.set_debug()
Slapd.set_dn_suffix()
Slapd.set_port()
Slapd.set_root_cn()
Slapd.set_root_password()
Slapd.set_slapd_debug_level()
Slapd.start()
Slapd.stop()
Slapd.wait()
delete_directory_content()
find_available_tcp_port()
is_port_in_use()
mkdirs()
quote()
test()
- Module contents
Submodules¶
tldap.dict module¶
Dictionary related classes.
- class tldap.dict.CaseInsensitiveDict(allowed_keys: Set[str], d: dict | None = None)[source]¶
Bases:
object
Case insensitve dictionary for searches however preserves the case for retrieval. Needs to be supplied with a set of allowed keys.
tldap.dn module¶
dn.py - misc stuff for handling distinguished names (see RFC 4514)
- tldap.dn.dn2str(dn)[source]¶
This function takes a decomposed DN as parameter and returns a single string. It’s the inverse to str2dn() but will always return a DN in LDAPv3 format compliant to RFC 4514.
- tldap.dn.escape_dn_chars(s)[source]¶
Escape all DN special characters found in s with a back-slash (see RFC 4514, section 2.4)
- tldap.dn.explode_dn(dn[, notypes=0]) list [source]¶
This function takes a DN and breaks it up into its component parts. The notypes parameter is used to specify that only the component’s attribute values be returned and not the attribute types.
tldap.exceptions module¶
Various TLDAP exceptions.
- exception tldap.exceptions.InvalidDN[source]¶
Bases:
Exception
DN value is invalid and cannot be parsed.
- exception tldap.exceptions.MultipleObjectsReturned[source]¶
Bases:
Exception
The query returned multiple objects when only one was expected.
- exception tldap.exceptions.ObjectAlreadyExists[source]¶
Bases:
Exception
The requested object already exists
- exception tldap.exceptions.ObjectDoesNotExist[source]¶
Bases:
Exception
The requested object does not exist
tldap.fields module¶
LDAP field types.
- class tldap.fields.BinaryField(max_instances=1, required=False)[source]¶
Bases:
Field
Field contains a binary value that can not be interpreted in anyway.
- class tldap.fields.CharField(max_instances=1, required=False)[source]¶
Bases:
Field
Field contains a UTF8 character string.
- class tldap.fields.DaysSinceEpochField(max_instances=1, required=False)[source]¶
Bases:
Field
Field is an integer containing number of days since epoch.
- class tldap.fields.FakeField(max_instances=1, required=False)[source]¶
Bases:
Field
- db_field = False¶
Field contains a binary value that can not be interpreted in anyway.
- class tldap.fields.Field(max_instances=1, required=False)[source]¶
Bases:
object
The base field type.
- clean(value)[source]¶
Convert the value’s type and run validation. Validation errors from to_python and validate are propagated. The correct value is returned if no error is raised.
- db_field = True¶
- property is_list¶
- to_python(value)[source]¶
Converts the input value into the expected Python data type, raising django.core.exceptions.ValidationError if the data can’t be converted. Returns the converted value. Subclasses should override this.
- validate(value)[source]¶
Validates value and throws ValidationError. Subclasses should override this to provide validation logic.
- class tldap.fields.IntegerField(max_instances=1, required=False)[source]¶
Bases:
Field
Field contains an integer value.
- class tldap.fields.SecondsSinceEpochField(max_instances=1, required=False)[source]¶
Bases:
Field
Field is an integer containing number of seconds since epoch.
- class tldap.fields.SidField(max_instances=1, required=False)[source]¶
Bases:
Field
Field is a binary representation of a Microsoft SID.
- class tldap.fields.UnicodeField(max_instances=1, required=False)[source]¶
Bases:
Field
Field contains a UTF16 character string.
tldap.filter module¶
filters.py - misc stuff for handling LDAP filter strings (see RFC2254)
tldap.ldap_passwd module¶
Hash and check passwords.
tldap.modlist module¶
This module contains a modifyModlist
function adopted from
ldap.modlist
.
- tldap.modlist.addModlist(entry: dict, ignore_attr_types: List[str] | None = None) Dict[str, List[bytes]] [source]¶
Build modify list for call of method LDAPObject.add()
- tldap.modlist.modifyModlist(old_entry: dict, new_entry: dict, ignore_attr_types: List[str] | None = None, ignore_oldexistent: bool = False) Dict[str, Tuple[str, List[bytes]]] [source]¶
Build differential modify list for calling LDAPObject.modify()/modify_s()
- Parameters:
old_entry – Dictionary holding the old entry
new_entry – Dictionary holding what the new entry should be
ignore_attr_types – List of attribute type names to be ignored completely
ignore_oldexistent – If true attribute type names which are in old_entry but are not found in new_entry at all are not deleted. This is handy for situations where your application sets attribute value to ‘’ for deleting an attribute. In most cases leave zero.
- Returns:
List of tuples suitable for
ldap.LDAPObject.modify()
.
This function is the same as
ldap.modlist.modifyModlist()
except for the following changes:MOD_DELETE/MOD_DELETE used in preference to MOD_REPLACE when updating an existing value.
tldap.query module¶
- tldap.query.get_filter(q: Q, fields: Dict[str, Field], pk: str)[source]¶
Translate the Q tree into a filter string to search for, or None if no results possible.
tldap.query_utils module¶
tldap.transaction module¶
This module implements a transaction manager that can be used to define transaction handling in a request or view function. It is used by transaction control middleware and decorators.
The transaction manager can be in managed or in auto state. Auto state means the system is using a commit-on-save strategy (actually it’s more like commit-on-change). As soon as the .save() or .delete() (or related) methods are called, a commit is made.
Managed transactions don’t do those commits, but will need some kind of manual or implicit commits or rollbacks.
- class tldap.transaction.Transaction(entering, exiting, using)[source]¶
Bases:
object
Acts as either a decorator, or a context manager. If it’s a decorator it takes a function and returns a wrapped function. If it’s a contextmanager it’s used with the
with
statement. In either event entering/exiting are called before and after, respectively, the function/block is executed.autocommit, commit_on_success, and commit_manually contain the implementations of entering and exiting.
- exception tldap.transaction.TransactionManagementError[source]¶
Bases:
Exception
This exception is thrown when something bad happens with transaction management.
- tldap.transaction.commit_manually(using=None)[source]¶
Decorator that activates manual transaction control. It just disables automatic transaction control and doesn’t do any commit/rollback of its own – it’s up to the user to call the commit and rollback functions themselves.
- tldap.transaction.commit_on_success(using=None)[source]¶
This decorator activates commit on response. This way, if the view function runs successfully, a commit is made; if the viewfunc produces an exception, a rollback is made. This is one of the most common ways to do transaction control in Web apps.
- tldap.transaction.enter_transaction_management(using=None)[source]¶
Enters transaction management for a running thread. It must be balanced with the appropriate leave_transaction_management call, since the actual state is managed as a stack.
The state and dirty flag are carried over from the surrounding block or from the settings, if there is no surrounding block (dirty is always false when no current block is running).
- tldap.transaction.is_dirty(using=None)[source]¶
Returns True if the current transaction requires a commit for changes to happen.
- tldap.transaction.is_managed(using=None)[source]¶
Checks whether the transaction manager is in manual or in auto state.
tldap.tree module¶
A class for storing a tree graph. Primarily used for filter constructs in the ORM.
- class tldap.tree.Node(children=None, connector=None, negated=False)[source]¶
Bases:
object
A single internal node in the tree graph. A Node should be viewed as a connection (the root) with the children being either leaf nodes or other Node instances.
- add(data, conn_type, squash=True)[source]¶
Combines this tree and the data represented by data using the connector conn_type. The combine is done by squashing the node other away if possible.
This tree (self) will never be pushed to a child node of the combined tree, nor will the connector or negated properties change.
The function returns a node which can be used in place of data regardless if the node other got squashed or not.
If squash is False the data is prepared and added as a child to this tree without further logic.
- default = 'DEFAULT'¶
tldap.utils module¶
Contains ConnectionHandler which represents a list of connections.
Module contents¶
Holds global stuff for tldap.
- Q
Shortcut to
tldap.query_utils.Q
, allows combining query terms.- DEFAULT_LDAP_ALIAS
Alias for default LDAP connection.