LDAP – lightweight directory access)¶
lsf – LDAP session factory¶
Module lsf
defines LdapSessionFactory
class which is
central point for your LDAP database access.
Analogy to summer.sf
.
-
class
summer.lsf.
LdapConnectionProvider
(base: str)[source]¶ Bases:
object
Class to be used as based for providing LDAP session.
See default implementation in
summer.lsf.DefaultLdapConnectionProvider
.-
server
¶ LDAP server property.
Returns: LDAP server instance Return type: ldap3.Server
-
base
¶ LDAP base property – convenience value defining portion of a LDAP subtree of interest.
Returns: Optional property, can be left empty; LDAP base DN for a subtree of interest to be used by queries Return type: str
-
create_connection
() → ldap3.core.connection.Connection[source]¶ Each call produces a new connection.
Returns: new instance of LDAP connection Return type: ldap3.Connection
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
summer.lsf.
LdapSessionFactory
(ldap_connection_provider: summer.lsf.LdapConnectionProvider)[source]¶ Bases:
object
Thread safe ldap3 session provider. Analogy to
summer.sf.SessionFactory
.-
class
Local
(ldap_connection_provider: summer.lsf.LdapConnectionProvider)[source]¶ Bases:
_thread._local
Thread local session wrapper.
There is an active
ldap3.Connection
instance inldap_session
attribute.-
base
¶ Delegates to
LdapConnectionProvider.base()
.
-
active
¶ Get status of current ldap session.
Returns: True if session is bound, False otherwise. Return type: bool
-
-
LdapSessionFactory.
__init__
(ldap_connection_provider: summer.lsf.LdapConnectionProvider)[source]¶ Creates
LdapSessionFactory
instance.Parameters: - ldap_connection_provider (LdapConnectionProvider) – LDAP connection provider
- base (str) – LDAP base dn
-
LdapSessionFactory.
base
¶ Delegates to
LdapSessionFactory.Local.base()
-
LdapSessionFactory.
session
¶ Get current thread-local ldap3 session wrapper (creating one, if non-existent).
Returns: existing or just created ldap3 session wrapper Return type: LdapSessionFactory.Local
-
LdapSessionFactory.
connection
¶ Delegates to
LdapSessionFactory.Local.connection()
-
LdapSessionFactory.
__weakref__
¶ list of weak references to the object (if defined)
-
class
ldapdao – LDAP data access object support¶
Provides LDAP DAO support. Analogy to summer.dao
module.
Base LdapDao
provides access to important properties:
LdapDao.connection()
property referencingldap3.Connection
LdapDao.base()
property referencingsummer.lsf.LdapSessionFactory.base
dn value (useful for creating LDAP queries)
-
class
summer.ldapdao.
LdapDao
(ldap_session_factory: summer.lsf.LdapSessionFactory)[source]¶ Bases:
object
Base DAO class. Analogy to
summer.dao.Dao
class.Provides safe access to thread bound session/connection through
session()
property and base LDAP dn value throughbase()
property.-
__init__
(ldap_session_factory: summer.lsf.LdapSessionFactory)[source]¶ Creates
LdapDao
instance.Parameters: ldap_session_factory (LdapSessionFactory) – ldap session factory to use
-
connection
¶ Delegates to
summer.lsf.LdapSessionFactory.connection()
.
-
session
¶ Compatibility alias for
LdapDao.connection
-
base
¶ Delegates to
summer.lsf.LdapSessionFactory.base()
.
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
summer.ldapdao.
LdapEntityDao
(ldap_session_factory: summer.lsf.LdapSessionFactory, clazz: type)[source]¶ Bases:
summer.ldapdao.LdapDao
Base DAO class for persistent classes subclassed from
summer.domain.LdapEntity
.-
__init__
(ldap_session_factory: summer.lsf.LdapSessionFactory, clazz: type)[source]¶ Creates
LdapEntityDao
.Parameters: - ldap_session_factory (LdapSessionFactory) – ldap session factory to use
- clazz (type) – reference to class type
-
clazz
¶ Get class type for this dao.
Returns: class for this EntityDao
Return type: type
-