diff options
author | Petr Viktorin <pviktori@redhat.com> | 2013-01-23 10:05:21 -0500 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-03-01 16:59:45 +0100 |
commit | 5184c312f6dd1a885c9e0e10e3763eddb8110bae (patch) | |
tree | b80d94b6fb94cb842aca6d65cc6f6be14b0ae5f0 /ipaserver/install | |
parent | d17f9020a847c7a6db7734f1525c59efe07fbdcd (diff) | |
download | freeipa-5184c312f6dd1a885c9e0e10e3763eddb8110bae.tar.gz freeipa-5184c312f6dd1a885c9e0e10e3763eddb8110bae.tar.xz freeipa-5184c312f6dd1a885c9e0e10e3763eddb8110bae.zip |
replace getEntry with get_entry (or get_entries if scope != SCOPE_BASE)
Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Diffstat (limited to 'ipaserver/install')
-rw-r--r-- | ipaserver/install/adtrustinstance.py | 25 | ||||
-rw-r--r-- | ipaserver/install/dsinstance.py | 2 | ||||
-rw-r--r-- | ipaserver/install/krbinstance.py | 8 | ||||
-rw-r--r-- | ipaserver/install/ldapupdate.py | 2 | ||||
-rw-r--r-- | ipaserver/install/replication.py | 41 | ||||
-rw-r--r-- | ipaserver/install/service.py | 2 |
6 files changed, 42 insertions, 38 deletions
diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py index 361587d08..c1121bd22 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 de902437f..272e0af72 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 26de08d46..2380d55f6 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 25ff49abd..2f2e7debe 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 1bd74b7b2..538cf92cf 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 39771887e..cc5bb877f 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 |