summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2014-11-21 20:08:17 +0100
committerJan Cholasta <jcholast@redhat.com>2015-04-16 06:58:31 +0000
commitc904dea06afd6bbf47367ee0b17c85a821a04d65 (patch)
tree5e9d69074d5c9942610f694aee59f2861f31968f /ipapython
parent8f263df2456c6c2ba4463c690bb69b3650356493 (diff)
downloadfreeipa-c904dea06afd6bbf47367ee0b17c85a821a04d65.tar.gz
freeipa-c904dea06afd6bbf47367ee0b17c85a821a04d65.tar.xz
freeipa-c904dea06afd6bbf47367ee0b17c85a821a04d65.zip
ldap: Add bind and unbind methods to LDAPClient
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipaldap.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 04b09f217..ace1af7dd 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -1238,6 +1238,41 @@ class LDAPClient(object):
# bypass ldap2's locking
object.__setattr__(self, '_conn', None)
+ def simple_bind(self, bind_dn, bind_password, server_controls=None,
+ client_controls=None):
+ """
+ Perform simple bind operation.
+ """
+ with self.error_handler():
+ self._conn.simple_bind_s(
+ bind_dn, bind_password, server_controls, client_controls)
+
+ def external_bind(self, user_name, server_controls=None,
+ client_controls=None):
+ """
+ Perform SASL bind operation using the SASL EXTERNAL mechanism.
+ """
+ with self.error_handler():
+ auth_tokens = ldap.sasl.external(user_name)
+ self._conn.sasl_interactive_bind_s(
+ None, auth_tokens, server_controls, client_controls)
+
+ def gssapi_bind(self, server_controls=None, client_controls=None):
+ """
+ Perform SASL bind operation using the SASL GSSAPI mechanism.
+ """
+ with self.error_handler():
+ auth_tokens = ldap.sasl.sasl({}, 'GSSAPI')
+ self._conn.sasl_interactive_bind_s(
+ None, auth_tokens, server_controls, client_controls)
+
+ def unbind(self):
+ """
+ Perform unbind operation.
+ """
+ with self.error_handler():
+ self.conn.unbind_s()
+
def make_dn_from_attr(self, attr, value, parent_dn=None):
"""
Make distinguished name from attribute.