flask_open_directory.base package¶
Submodules¶
flask_open_directory.base.open_directory_abc module¶
-
class
flask_open_directory.base.open_directory_abc.OpenDirectoryABC[source]¶ Bases:
objectThis
abchas all the methods that should be implemented for an object to be considered a validOpenDirectorysubclass.All of the methods must be implemented to create a subclass, or to pass an
isinstanceorissubclasscheck.-
base_dn¶ Return the base ldap domain. Used to build ldap queries.
Return type: str
-
connection¶ An
ldap3.Connectionused for queries. This should only return a connection if there is a flask application running with the connection stored on it.Return type: Optional[Connection]
-
connection_ctx()[source]¶ A context manager to yield an
ldap3.Connection, this should try to create a connection regardless of if a flask application is running.Return type: ContextManager[]
-
server_url¶ Return the ldap server url. Used for the ldap connection.
Return type: str
-
Module contents¶
-
class
flask_open_directory.base.OpenDirectoryABC[source]¶ Bases:
objectThis
abchas all the methods that should be implemented for an object to be considered a validOpenDirectorysubclass.All of the methods must be implemented to create a subclass, or to pass an
isinstanceorissubclasscheck.-
base_dn¶ Return the base ldap domain. Used to build ldap queries.
Return type: str
-
connection¶ An
ldap3.Connectionused for queries. This should only return a connection if there is a flask application running with the connection stored on it.Return type: Optional[Connection]
-
connection_ctx()[source]¶ A context manager to yield an
ldap3.Connection, this should try to create a connection regardless of if a flask application is running.Return type: ContextManager[]
-
server_url¶ Return the ldap server url. Used for the ldap connection.
Return type: str
-
-
class
flask_open_directory.base.BaseOpenDirectory(**config)[source]¶ Bases:
flask_open_directory.base.open_directory_abc.OpenDirectoryABCImplements the
OpenDirectoryABC.This stores all kwargs into a
configattribute, which is used to get the server url and an optional base dn.-
base_dn¶ Return the base dn for the open directory server. This looks in the
configdict for key ‘OPEN_DIRECTORY_BASE_DN’ and if nothing is found it will create one from theserver_url.Note
If your server url is an ip address, then you need to set this in the config.
Return type: str
-
connect()[source]¶ Create’s an
ldap3.Connection, that will need to be managed by the caller (closed, cleanup, etc). This is primarily used when there is a flask application running. It is better to use theconnection_ctxcontext manager.Return type: Connection
-
connection¶ Return’s a shared connection when a flask application is running. If there is not flask application running, then this property will return
None.If you need a connection outside of a flask application context, then you can create one with the
connectmethod or use theconnection_ctxmethod, which works the same with or without an application context.Return type: Union[None,Connection]
-
connection_ctx()[source]¶ A context manager that will use the shared connection if a flask application context is available if not it will create a connection for running one-off commands.
Return type: ContextManager[]
-
create_server()[source]¶ Create’s a
ldap3.Serverwith this instancesserver_url. This method is typically only used internally.Return type: Server
-
server_url¶ Return the server url for an instance. This looks in the
configdict for key ‘OPEN_DIRECTORY_SERVER’ and if noting is found it returns_default_serverset on the class (default ‘localhost’).Return type: str
-