On 02/11/2013 02:07 PM, Petr Viktorin wrote:
On 02/01/2013 03:38 PM, Petr Viktorin wrote:
On 02/01/2013 10:24 AM, Jan Cholasta wrote:
On 1.2.2013 09:47, Petr Viktorin wrote:
On 01/31/2013 07:01 PM, Jan Cholasta wrote:
On 31.1.2013 11:00, Petr Viktorin wrote:
On 01/30/2013 10:53 AM, Petr Viktorin wrote:
On 01/29/2013 04:39 PM, Petr Viktorin wrote:
On 01/28/2013 04:09 PM, Petr Viktorin wrote:
On 01/28/2013 09:34 AM, Jan Cholasta wrote:
On 25.1.2013 14:54, Petr Viktorin wrote:
On 01/24/2013 03:06 PM, Petr Viktorin wrote:
On 01/24/2013 10:43 AM, Petr Viktorin wrote:
On 01/22/2013 04:04 PM, Petr Viktorin wrote:
On 01/21/2013 06:38 PM, Petr Viktorin wrote:
On 01/17/2013 06:27 PM, Petr Viktorin wrote:
Hello,
This is the first batch of changes aimed to consolidate our
LDAP
code.
Each should be a self-contained change that doesn't break
anything.

[...]
Since this patchset is becoming unwieldy, I've put it in a
public
repo
that I'll keep updated. The following command will fetch it into
your
"pviktori-ldap-refactor" branch:

     git fetch git://github.com/encukou/freeipa
ldap-refactor:pviktori-ldap-refactor


[...]

I would prefer if you used the semantics of .get() for
.get_single() as
well (i.e. when no default value is provided, None is assumed) in
patch
152. Or is there a reason not to?

I think you should always have to write extra code to supress
exceptions
(“Errors should never pass silently”). In Python, the easiest/shortest
getter you can write will typically raise an exception when the
value is
missing (e.g. `d[k]` for dicts, `getattr(a, b)` for objects).


That is true, but I think consistency is more important here - the name
suggests the method behaves the same way .get() does. If you insist on
keeping the current behavior, would you at least consider renaming the
method (perhaps to just "single" or "single_value")?

(This is just a nitpick, so don't worry too much about it.)

Alright, I renamed get_single to single_value().

I also rebased to current master.

Updating patch 115 to take recent changes in replica-manage into account.


Patches 161 & 167 needed a rebase.

--
Petr³
From 80cccf74af15207fd6eed5e3e46e81350a3b4201 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 23 Jan 2013 10:05:21 -0500
Subject: [PATCH] replace getEntry with get_entry (or get_entries if scope !=
 SCOPE_BASE)

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
---
 install/tools/ipa-csreplica-manage   |    6 ++--
 install/tools/ipa-managed-entries    |    7 +----
 install/tools/ipa-replica-manage     |    8 +++---
 ipaserver/install/adtrustinstance.py |   25 +++++++++-----------
 ipaserver/install/dsinstance.py      |    2 +-
 ipaserver/install/krbinstance.py     |    8 ++++--
 ipaserver/install/ldapupdate.py      |    2 +-
 ipaserver/install/replication.py     |   41 +++++++++++++++++++---------------
 ipaserver/install/service.py         |    2 +-
 ipaserver/ipaldap.py                 |   21 ++++-------------
 10 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/install/tools/ipa-csreplica-manage b/install/tools/ipa-csreplica-manage
index 5cab8b8642c4fd9113c6eb4a4aeab1b4b502cfb5..3f10c9003482c6f3903f70fd9eb59b8c469b8f42 100755
--- a/install/tools/ipa-csreplica-manage
+++ b/install/tools/ipa-csreplica-manage
@@ -135,7 +135,7 @@ class CSReplicationManager(replication.ReplicationManager):
                 try:
                     cn="%sAgreement1-%s-%s" % (master, host, instance_name)
                     dn = DN(('cn', cn), self.replica_dn())
-                    self.conn.getEntry(dn, ldap.SCOPE_BASE)
+                    self.conn.get_entry(dn)
                     return (cn, dn)
                 except errors.NotFound:
                     dn = None
@@ -156,7 +156,7 @@ class CSReplicationManager(replication.ReplicationManager):
 
     def has_ipaca(self):
         try:
-            entry = self.conn.getEntry(self.suffix, ldap.SCOPE_BASE)
+            entry = self.conn.get_entry(self.suffix)
         except errors.NotFound:
             return False
         else:
@@ -216,7 +216,7 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose):
         for ent in entries:
             try:
                 cadn = DN(('cn', 'CA'), DN(ent.dn))
-                entry = conn.getEntry(cadn, ldap.SCOPE_BASE)
+                entry = conn.get_entry(cadn)
                 peers[ent.single_value('cn')] = ['master', '']
             except errors.NotFound:
                 peers[ent.single_value('cn')] = ['CA not configured', '']
diff --git a/install/tools/ipa-managed-entries b/install/tools/ipa-managed-entries
index 11deb63c32ff59a36276bbee063fb55740088343..b7dbdb9d3ed9930bd3eec35bbc117e061bc26300 100755
--- a/install/tools/ipa-managed-entries
+++ b/install/tools/ipa-managed-entries
@@ -143,11 +143,8 @@ def main():
 
         disabled = True
         try:
-            entry = conn.getEntry(def_dn,
-                ldap.SCOPE_BASE,
-                filter,
-                ['originfilter'],
-            )
+            [entry] = conn.get_entries(def_dn, ldap.SCOPE_BASE,
+                                       filter, ['originfilter'])
             disable_attr = '(objectclass=disable)'
             try:
                 org_filter = entry.single_value('originfilter', None)
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index c542c0757b4d396fd0d189c518da74b1a51c019f..585d40c654011d613a1d66d8e248596ae048f13a 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -765,12 +765,12 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
             master1_dn = DN(('cn', replica1), masters_dn)
             master2_dn = DN(('cn', replica2), masters_dn)
 
-            repl1.conn.getEntry(master1_dn, ldap.SCOPE_BASE)
-            repl1.conn.getEntry(master2_dn, ldap.SCOPE_BASE)
+            repl1.conn.get_entry(master1_dn)
+            repl1.conn.get_entry(master2_dn)
 
             repl2 = replication.ReplicationManager(realm, replica2, dirman_passwd)
-            repl2.conn.getEntry(master1_dn, ldap.SCOPE_BASE)
-            repl2.conn.getEntry(master2_dn, ldap.SCOPE_BASE)
+            repl2.conn.get_entry(master1_dn)
+            repl2.conn.get_entry(master2_dn)
 
         except errors.NotFound:
             standard_logging_setup(console_format='%(message)s')
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py
index e42bac21d829d2c002e2c2194377f094afececef..5e160b734bc32006c728021037f111ac23063614 100644
--- a/ipaserver/install/adtrustinstance.py
+++ b/ipaserver/install/adtrustinstance.py
@@ -158,8 +158,7 @@ class ADTRUSTInstance(service.Service):
         admin_group_dn = DN(('cn', 'admins'), api.env.container_group,
                             self.suffix)
         try:
-            dom_entry = self.admin_conn.getEntry(self.smb_dom_dn, \
-                                                 ldap.SCOPE_BASE)
+            dom_entry = self.admin_conn.get_entry(self.smb_dom_dn)
         except errors.NotFound:
             self.print_msg("Samba domain object not found")
             return
@@ -170,14 +169,13 @@ class ADTRUSTInstance(service.Service):
             return
 
         try:
-            admin_entry = self.admin_conn.getEntry(admin_dn, ldap.SCOPE_BASE)
+            admin_entry = self.admin_conn.get_entry(admin_dn)
         except:
             self.print_msg("IPA admin object not found")
             return
 
         try:
-            admin_group_entry = self.admin_conn.getEntry(admin_group_dn, \
-                                                         ldap.SCOPE_BASE)
+            admin_group_entry = self.admin_conn.get_entry(admin_group_dn)
         except:
             self.print_msg("IPA admin group object not found")
             return
@@ -218,8 +216,7 @@ class ADTRUSTInstance(service.Service):
         self.ldap_connect()
 
         try:
-            dom_entry = self.admin_conn.getEntry(self.smb_dom_dn, \
-                                                 ldap.SCOPE_BASE)
+            dom_entry = self.admin_conn.get_entry(self.smb_dom_dn)
         except errors.NotFound:
             self.print_msg("Samba domain object not found")
             return
@@ -231,7 +228,7 @@ class ADTRUSTInstance(service.Service):
         fb_group_dn = DN(('cn', self.FALLBACK_GROUP_NAME),
                          api.env.container_group, self.suffix)
         try:
-            self.admin_conn.getEntry(fb_group_dn, ldap.SCOPE_BASE)
+            self.admin_conn.get_entry(fb_group_dn)
         except errors.NotFound:
             try:
                 self._ldap_mod('default-smb-group.ldif', self.sub_dict)
@@ -242,7 +239,7 @@ class ADTRUSTInstance(service.Service):
         # _ldap_mod does not return useful error codes, so we must check again
         # if the fallback group was created properly.
         try:
-            self.admin_conn.getEntry(fb_group_dn, ldap.SCOPE_BASE)
+            self.admin_conn.get_entry(fb_group_dn)
         except errors.NotFound:
             self.print_msg("Failed to add fallback group.")
             return
@@ -310,7 +307,7 @@ class ADTRUSTInstance(service.Service):
     def __create_samba_domain_object(self):
 
         try:
-            self.admin_conn.getEntry(self.smb_dom_dn, ldap.SCOPE_BASE)
+            self.admin_conn.get_entry(self.smb_dom_dn)
             if self.reset_netbios_name:
                 self.__reset_netbios_name()
             else :
@@ -323,7 +320,7 @@ class ADTRUSTInstance(service.Service):
                        DN(('cn', 'ad'), self.trust_dn), \
                        DN(api.env.container_cifsdomains, self.suffix)):
             try:
-                self.admin_conn.getEntry(new_dn, ldap.SCOPE_BASE)
+                self.admin_conn.get_entry(new_dn)
             except errors.NotFound:
                 try:
                     name = new_dn[1].attr
@@ -365,7 +362,7 @@ class ADTRUSTInstance(service.Service):
         try:
             plugin_dn = DN(('cn', plugin_cn), ('cn', 'plugins'),
                            ('cn', 'config'))
-            self.admin_conn.getEntry(plugin_dn, ldap.SCOPE_BASE)
+            self.admin_conn.get_entry(plugin_dn)
             self.print_msg('%s plugin already configured, nothing to do' % name)
         except errors.NotFound:
             try:
@@ -713,8 +710,8 @@ class ADTRUSTInstance(service.Service):
             return
 
         try:
-            entry = self.admin_conn.getEntry(DN(('cn', 'admins'), api.env.container_group, self.suffix),
-                                             ldap.SCOPE_BASE)
+            entry = self.admin_conn.get_entry(
+                DN(('cn', 'admins'), api.env.container_group, self.suffix))
         except errors.NotFound:
             raise ValueError("No local ID range and no admins group found.\n" \
                              "Add local ID range manually and try again!")
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
index de902437f966b881164d12abcff934e24b0ec0fe..272e0af72907f29d49b854434b1fa98f8aa9a494 100644
--- a/ipaserver/install/dsinstance.py
+++ b/ipaserver/install/dsinstance.py
@@ -832,7 +832,7 @@ class DsInstance(service.Service):
 
         dn = DN(('cn', 'default'), ('ou', 'profile'), self.suffix)
         try:
-            entry = self.admin_conn.getEntry(dn, ldap.SCOPE_BASE, '(objectclass=*)')
+            entry = self.admin_conn.get_entry(dn)
             srvlist = entry.single_value('defaultServerList', '')
             srvlist = srvlist.split()
             if not self.fqdn in srvlist:
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 26de08d46372a2b0edcd59e506f0acf11614f40b..2380d55f68c69fcd075a85fba68e46525020b227 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -103,7 +103,7 @@ class KrbInstance(service.Service):
         """
 
         service_dn = DN(('krbprincipalname', principal), self.get_realm_suffix())
-        service_entry = self.admin_conn.getEntry(service_dn, ldap.SCOPE_BASE)
+        service_entry = self.admin_conn.get_entry(service_dn)
         self.admin_conn.delete_entry(service_entry)
 
         # Create a host entry for this master
@@ -359,8 +359,10 @@ class KrbInstance(service.Service):
 
     def __write_stash_from_ds(self):
         try:
-            entry = self.admin_conn.getEntry(self.get_realm_suffix(),
-                                             ldap.SCOPE_SUBTREE)
+            entries = self.admin_conn.get_entries(self.get_realm_suffix(),
+                                                  ldap.SCOPE_SUBTREE)
+            # TODO: Ensure we got only one entry
+            entry = entries[0]
         except errors.NotFound, e:
             root_logger.critical("Could not find master key in DS")
             raise e
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 25ff49abd4ba054c7b634b3563b16938daaba696..2f2e7debe43f096ebf6b6d8f52e49534cb3fec5f 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -450,7 +450,7 @@ class LDAPUpdate:
 
         while True:
             try:
-                entry = self.conn.getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
+                entry = self.conn.get_entry(dn, attrlist)
             except errors.NotFound, e:
                 self.error("Task not found: %s", dn)
                 return
diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index 46a489b07744d6aa791fee5d0a2d280e35b51406..8c5c4a880df7a87271aa5b848315f3136a0bd7f3 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -100,8 +100,9 @@ def enable_replication_version_checking(hostname, realm, dirman_passwd):
         conn.do_simple_bind(bindpw=dirman_passwd)
     else:
         conn.do_sasl_gssapi_bind()
-    entry = conn.getEntry(DN(('cn', 'IPA Version Replication'), ('cn', 'plugins'), ('cn', 'config')),
-                          ldap.SCOPE_BASE, 'objectclass=*')
+    entry = conn.get_entry(DN(('cn', 'IPA Version Replication'),
+                              ('cn', 'plugins'),
+                              ('cn', 'config')))
     if entry.single_value('nsslapd-pluginenabled', None) == 'off':
         conn.modify_s(entry.dn, [(ldap.MOD_REPLACE, 'nsslapd-pluginenabled', 'on')])
         conn.unbind()
@@ -179,7 +180,7 @@ class ReplicationManager(object):
         dn = self.replica_dn()
         assert isinstance(dn, DN)
         try:
-            replica = conn.getEntry(dn, ldap.SCOPE_BASE, "objectclass=*")
+            replica = conn.get_entry(dn)
         except errors.NotFound:
             pass
         else:
@@ -191,7 +192,7 @@ class ReplicationManager(object):
         retval = -1
         dn = DN(('cn','replication'),('cn','etc'), self.suffix)
         try:
-            replica = master_conn.getEntry(dn, ldap.SCOPE_BASE, "objectclass=*")
+            replica = master_conn.get_entry(dn)
         except errors.NotFound:
             root_logger.debug("Unable to retrieve nsDS5ReplicaId from remote server")
             raise
@@ -350,7 +351,7 @@ class ReplicationManager(object):
         assert isinstance(dn, DN)
 
         try:
-            entry = conn.getEntry(dn, ldap.SCOPE_BASE)
+            entry = conn.get_entry(dn)
             managers = entry.get('nsDS5ReplicaBindDN')
             for m in managers:
                 if replica_binddn == DN(m):
@@ -445,22 +446,26 @@ class ReplicationManager(object):
 
     def get_mapping_tree_entry(self):
         try:
-            entry = self.conn.getEntry(DN(('cn', 'mapping tree'), ('cn', 'config')), ldap.SCOPE_ONELEVEL,
-                                       "(cn=\"%s\")" % (self.suffix))
+            entries = self.conn.get_entries(
+                DN(('cn', 'mapping tree'), ('cn', 'config')),
+                ldap.SCOPE_ONELEVEL,
+                "(cn=\"%s\")" % (self.suffix))
+            # TODO: Check we got only one entry
+            return entries[0]
         except errors.NotFound:
             root_logger.debug(
                 "failed to find mapping tree entry for %s" % self.suffix)
             raise
 
-        return entry
-
 
     def enable_chain_on_update(self, bename):
         mtent = self.get_mapping_tree_entry()
         dn = mtent.dn
 
-        plgent = self.conn.getEntry(DN(('cn', 'Multimaster Replication Plugin'), ('cn', 'plugins'), ('cn', 'config')),
-                                    ldap.SCOPE_BASE, "(objectclass=*)", ['nsslapd-pluginPath'])
+        plgent = self.conn.get_entry(
+            DN(('cn', 'Multimaster Replication Plugin'), ('cn', 'plugins'),
+               ('cn', 'config')),
+            ['nsslapd-pluginPath'])
         path = plgent.single_value('nsslapd-pluginPath', None)
 
         mod = [(ldap.MOD_REPLACE, 'nsslapd-state', 'backend'),
@@ -481,7 +486,7 @@ class ReplicationManager(object):
         pass_dn = DN(('uid', 'passsync'), ('cn', 'sysaccounts'), ('cn', 'etc'), self.suffix)
         print "The user for the Windows PassSync service is %s" % pass_dn
         try:
-            conn.getEntry(pass_dn, ldap.SCOPE_BASE)
+            conn.get_entry(pass_dn)
             print "Windows PassSync entry exists, not resetting password"
             return
         except errors.NotFound:
@@ -498,7 +503,7 @@ class ReplicationManager(object):
 
         # Add it to the list of users allowed to bypass password policy
         extop_dn = DN(('cn', 'ipa_pwd_extop'), ('cn', 'plugins'), ('cn', 'config'))
-        entry = conn.getEntry(extop_dn, ldap.SCOPE_BASE)
+        entry = conn.get_entry(extop_dn)
         pass_mgrs = entry.get('passSyncManagersDNs')
         if not pass_mgrs:
             pass_mgrs = []
@@ -557,7 +562,7 @@ class ReplicationManager(object):
 
         cn, dn = self.agreement_dn(b_hostname, master=master)
         try:
-            a_conn.getEntry(dn, ldap.SCOPE_BASE)
+            a_conn.get_entry(dn)
             return
         except errors.NotFound:
             pass
@@ -756,7 +761,7 @@ class ReplicationManager(object):
                     'nsds5ReplicaLastInitStatus',
                     'nsds5ReplicaLastInitStart',
                     'nsds5ReplicaLastInitEnd']
-        entry = conn.getEntry(agmtdn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
+        entry = conn.get_entry(agmtdn, attrlist)
         if not entry:
             print "Error reading status from agreement", agmtdn
             hasError = 1
@@ -793,7 +798,7 @@ class ReplicationManager(object):
         attrlist = ['cn', 'nsds5replicaUpdateInProgress',
                     'nsds5ReplicaLastUpdateStatus', 'nsds5ReplicaLastUpdateStart',
                     'nsds5ReplicaLastUpdateEnd']
-        entry = conn.getEntry(agmtdn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
+        entry = conn.get_entry(agmtdn, attrlist)
         if not entry:
             print "Error reading status from agreement", agmtdn
             hasError = 1
@@ -1066,7 +1071,7 @@ class ReplicationManager(object):
     def get_agreement_type(self, hostname):
         cn, dn = self.agreement_dn(hostname)
 
-        entry = self.conn.getEntry(dn, ldap.SCOPE_BASE)
+        entry = self.conn.get_entry(dn)
 
         objectclass = entry.get("objectclass")
 
@@ -1165,7 +1170,7 @@ class ReplicationManager(object):
 
         try:
             dn = DN(('cn', 'default'), ('ou', 'profile'), self.suffix)
-            ret = self.conn.getEntry(dn, ldap.SCOPE_BASE, '(objectclass=*)')
+            ret = self.conn.get_entry(dn)
             srvlist = ret.single_value('defaultServerList', '')
             srvlist = srvlist[0].split()
             if replica in srvlist:
diff --git a/ipaserver/install/service.py b/ipaserver/install/service.py
index 39771887e44b34134526827aee3efaec3f279395..cc5bb877ff6ea358ca89524d6b78596317b31098 100644
--- a/ipaserver/install/service.py
+++ b/ipaserver/install/service.py
@@ -188,7 +188,7 @@ class Service(object):
 
         dn = DN(('krbprincipalname', principal), ('cn', self.realm), ('cn', 'kerberos'), self.suffix)
         try:
-            entry = self.admin_conn.getEntry(dn, ldap.SCOPE_BASE)
+            entry = self.admin_conn.get_entry(dn)
         except errors.NotFound:
             # There is no service in the wrong location, nothing to do.
             # This can happen when installing a replica
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index 2cd90fc34025c70eba4f87d37b8e71902662bebe..107eb5ff1b8ca1053edd39d5db6daf1a608bf362 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -1622,17 +1622,6 @@ class IPAdmin(LDAPClient):
         self.__bind_with_wait(
             self.sasl_interactive_bind_s, timeout, None, auth_tokens)
 
-    def getEntry(self, base, scope, filterstr='(objectClass=*)',
-                 attrlist=None):
-        # FIXME: for backwards compatibility only
-        result, truncated = self.find_entries(
-            filter=filterstr,
-            attrs_list=attrlist,
-            base_dn=base,
-            scope=scope,
-        )
-        return result[0]
-
     def updateEntry(self,dn,oldentry,newentry):
         # FIXME: for backwards compatibility only
         """This wraps the mod function. It assumes that the entry is already
@@ -1729,7 +1718,6 @@ class IPAdmin(LDAPClient):
         return True
 
     def waitForEntry(self, dn, timeout=7200, attr='', quiet=True):
-        scope = ldap.SCOPE_BASE
         filter = "(objectclass=*)"
         attrlist = []
         if attr:
@@ -1748,10 +1736,11 @@ class IPAdmin(LDAPClient):
         entry = None
         while not entry and int(time.time()) < timeout:
             try:
-                entry = self.getEntry(dn, scope, filter, attrlist)
-            except ldap.NO_SUCH_OBJECT:
-                pass # no entry yet
-            except ldap.LDAPError, e: # badness
+                [entry] = self.get_entries(
+                    dn, ldap.SCOPE_BASE, filter, attrlist)
+            except errors.NotFound:
+                pass  # no entry yet
+            except Exception, e:  # badness
                 print "\nError reading entry", dn, e
                 break
             if not entry:
-- 
1.7.7.6

From b24dabe8beaf765f0c969ce289be6cee53c2d379 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Tue, 29 Jan 2013 12:01:36 -0500
Subject: [PATCH] Remove IPAdmin.sasl_interactive_bind_s

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
---
 ipaserver/dcerpc.py  |    2 +-
 ipaserver/ipaldap.py |    8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py
index 6243ebbb92e501dfb0919353d38a7a0af64183c0..2d531470dbb95b5ecf371f86f26d04288f89e671 100644
--- a/ipaserver/dcerpc.py
+++ b/ipaserver/dcerpc.py
@@ -420,7 +420,7 @@ class DomainValidator(object):
                 # OPT_X_SASL_NOCANON is used to avoid hard requirement for PTR
                 # records pointing back to the same host name
                 conn.set_option(_ldap.OPT_X_SASL_NOCANON, _ldap.OPT_ON)
-                conn.sasl_interactive_bind_s(None, sasl_auth)
+                conn.do_sasl_gssapi_bind()
                 if basedn is None:
                     # Use domain root base DN
                     basedn = DN(*map(lambda p: ('dc', p), info['dns_domain'].split('.')))
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index 6ad02a58203d4c3e99ce10224b03a4827bb23207..ed4a4fb4c86a3feed4b71f1845bcbd562c050606 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -1618,12 +1618,12 @@ class IPAdmin(LDAPClient):
 
     def do_sasl_gssapi_bind(self, timeout=DEFAULT_TIMEOUT):
         self.__bind_with_wait(
-            self.sasl_interactive_bind_s, timeout, None, SASL_AUTH)
+            self.conn.sasl_interactive_bind_s, timeout, None, SASL_AUTH)
 
     def do_external_bind(self, user_name=None, timeout=DEFAULT_TIMEOUT):
         auth_tokens = ldap.sasl.external(user_name)
         self.__bind_with_wait(
-            self.sasl_interactive_bind_s, timeout, None, auth_tokens)
+            self.conn.sasl_interactive_bind_s, timeout, None, auth_tokens)
 
     def updateEntry(self,dn,oldentry,newentry):
         # FIXME: for backwards compatibility only
@@ -1713,10 +1713,6 @@ class IPAdmin(LDAPClient):
         # FIXME: for backwards compatibility only
         return self.conn.set_option(*args, **kwargs)
 
-    def sasl_interactive_bind_s(self, *args, **kwargs):
-        # FIXME: for backwards compatibility only
-        return self.conn.sasl_interactive_bind_s(*args, **kwargs)
-
     def encode(self, *args, **kwargs):
         # FIXME: for backwards compatibility only
         return self.conn.encode(*args, **kwargs)
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to