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:
object
This
abc
has all the methods that should be implemented for an object to be considered a validOpenDirectory
subclass.All of the methods must be implemented to create a subclass, or to pass an
isinstance
orissubclass
check.-
base_dn
¶ Return the base ldap domain. Used to build ldap queries.
Return type: str
-
connection
¶ An
ldap3.Connection
used 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:
object
This
abc
has all the methods that should be implemented for an object to be considered a validOpenDirectory
subclass.All of the methods must be implemented to create a subclass, or to pass an
isinstance
orissubclass
check.-
base_dn
¶ Return the base ldap domain. Used to build ldap queries.
Return type: str
-
connection
¶ An
ldap3.Connection
used 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.OpenDirectoryABC
Implements the
OpenDirectoryABC
.This stores all kwargs into a
config
attribute, 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
config
dict 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_ctx
context 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
connect
method or use theconnection_ctx
method, 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.Server
with 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
config
dict for key ‘OPEN_DIRECTORY_SERVER’ and if noting is found it returns_default_server
set on the class (default ‘localhost’).Return type: str
-