summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorTomas Krizek <tkrizek@redhat.com>2016-10-05 17:42:32 +0200
committerMartin Basti <mbasti@redhat.com>2016-11-07 11:34:03 +0100
commitde58a5c60596de8b45c8016c3318bac78305477a (patch)
tree80ea270b7dd694ab2ecd6404526e156858758260 /ipapython
parent5760b7e983da6bda8f5383d9079551e4acb4c2da (diff)
downloadfreeipa-de58a5c60596de8b45c8016c3318bac78305477a.tar.gz
freeipa-de58a5c60596de8b45c8016c3318bac78305477a.tar.xz
freeipa-de58a5c60596de8b45c8016c3318bac78305477a.zip
ipaldap: merge simple_bind into LDAPClient
* Use LDAPClient.simple_bind instead of extra call to IPAdmin.do_simple_bind * Rename binddn to bind_dn * Rename bindpw to bind_password * Explicitly specify bind_dn in all calls https://fedorahosted.org/freeipa/ticket/6461 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipaldap.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 6506bed34..c4f8c7c2e 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -61,6 +61,8 @@ TRUNCATED_SIZE_LIMIT = object()
TRUNCATED_TIME_LIMIT = object()
TRUNCATED_ADMIN_LIMIT = object()
+DIRMAN_DN = DN(('cn', 'directory manager'))
+
def unicode_from_utf8(val):
'''
@@ -1050,6 +1052,7 @@ class LDAPClient(object):
def __enter__(self):
return self
+
def __exit__(self, exc_type, exc_value, traceback):
self.close()
@@ -1075,8 +1078,6 @@ class LDAPClient(object):
"""
with self.error_handler():
self._flush_schema()
- if bind_dn is None:
- bind_dn = DN()
assert isinstance(bind_dn, DN)
bind_dn = str(bind_dn)
bind_password = self.encode(bind_password)
@@ -1630,10 +1631,6 @@ class IPAdmin(LDAPClient):
def __str__(self):
return self.host + ":" + str(self.port)
- def do_simple_bind(self, binddn=DN(('cn', 'directory manager')),
- bindpw=""):
- self.simple_bind(binddn, bindpw)
-
def do_sasl_gssapi_bind(self):
self.gssapi_bind()
@@ -1642,7 +1639,7 @@ class IPAdmin(LDAPClient):
def do_bind(self, dm_password="", autobind=AUTOBIND_AUTO):
if dm_password:
- self.do_simple_bind(bindpw=dm_password)
+ self.simple_bind(bind_dn=DIRMAN_DN, bind_password=dm_password)
return
if autobind != AUTOBIND_DISABLED and os.getegid() == 0 and self.ldapi:
try: