_origen._origen_metal.utils.ldap#

Classes#

  • LDAP: A single LDAP instance

class _origen._origen_metal.utils.ldap.LDAP(name, server, base, auth=None, continuous_bind=None, populate_user_config=None, timeout=None)#

A single LDAP instance

auth#

Retrieves this LDAP’s authentication configuration after resolution

auth_config#

Retrieves this LDAP’s authentication configuration

base#

Retrieves the base DNs

bind(self) bool#

Attempts to bind using its current Auth settings.

Returns:

True if the bind was successful. Raises an error otherwise. Note this method will never return False.

Return type:

bool

bound#

Indicates whether this LDAP is currently bound. Returns true only if previously bound and the bind attempt was successful

continuous_bind#
name#

Retrieves this LDAP’s name. Does not actually influence anything in the connection itself

populate_user(user, dataset)#
populate_user_config#
search(filter: str, attrs: list) dict#

Runs a search with the given filters and attribute list. Returns a nested dict where the first level are the returned DNs. Each DN is a tuple with exactly two items in this order: (returned data, binary returned data). Whether or not your query returns data, binary data, or both is dependent on the server configuration and query itself.

Parameters:
  • filter (str) – Search criteria formatted as an filters

  • attrs (list) – List of attributes to retrieve from matching search criteria. An empty list returns all available attributes, equivalent to [“*”]

Returns:

Nested dict where the first level is the returned DNs. Each DN is a tuple with exactly two items in this order: (returned data, binary returned data). Whether or not your query returns data, binary data, or both is dependent on the server configuration and query itself.

Return type:

dict

See also

server#

Retrieves the server this LDAP was instantiated with

Similar to :meth:search except that this removes the first dict layer when a single DN is expected.

Parameters:
  • filter (str) – Search criteria formatted as an filters, expecting to yield at most one DN.

  • attrs (list) – List of attributes to retrieve from matching search criteria. An empty list returns all available attributes, equivalent to [“*”]

Returns:

Two-item tuple, each item being a dict corresponding to (returned data, binary returned data) respectively.

Return type:

tuple

timeout#
unbind()#
validate_credentials(username, password)#