diff options
author | Jan Cholasta <jcholast@redhat.com> | 2014-11-21 20:08:17 +0100 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-04-16 06:58:31 +0000 |
commit | c904dea06afd6bbf47367ee0b17c85a821a04d65 (patch) | |
tree | 5e9d69074d5c9942610f694aee59f2861f31968f /ipapython | |
parent | 8f263df2456c6c2ba4463c690bb69b3650356493 (diff) | |
download | freeipa-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.py | 35 |
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. |