mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Remove search_s and search_ext_s from IPAdmin
Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
This commit is contained in:
committed by
Martin Kosek
parent
d7bf70902b
commit
8f44811a95
@@ -394,14 +394,14 @@ def add_link(realm, replica1, replica2, dirman_passwd, options):
|
||||
|
||||
dn = DN(('cn', 'CA'), ('cn', replica2), ('cn', 'masters'), ('cn', 'ipa'), ('cn', 'etc'),
|
||||
ipautil.realm_to_suffix(realm))
|
||||
conn.search_s(dn, ldap.SCOPE_ONELEVEL)
|
||||
conn.get_entries(dn, ldap.SCOPE_ONELEVEL)
|
||||
conn.unbind_s()
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
except errors.NotFound:
|
||||
sys.exit('%s does not have a CA configured.' % replica2)
|
||||
except ldap.SERVER_DOWN, e:
|
||||
sys.exit("Unable to connect to %s: %s" % (ipautil.format_netloc(replica2, 636), convert_error(e)))
|
||||
except errors.NetworkError, e:
|
||||
sys.exit("Unable to connect to %s: %s" % (ipautil.format_netloc(replica2, 636), str(e)))
|
||||
except Exception, e:
|
||||
sys.exit("Failed to get data while trying to bind to '%s': %s" % (replica1, convert_error(e)))
|
||||
sys.exit("Failed to get data while trying to bind to '%s': %s" % (replica1, str(e)))
|
||||
|
||||
try:
|
||||
repl1 = get_cs_replication_manager(realm, replica1, dirman_passwd)
|
||||
@@ -434,8 +434,10 @@ def re_initialize(realm, options):
|
||||
thishost = installutils.get_fqdn()
|
||||
|
||||
filter = repl.get_agreement_filter(host=thishost)
|
||||
entry = repl.conn.search_s(DN(('cn', 'config')), ldap.SCOPE_SUBTREE, filter)
|
||||
if len(entry) == 0:
|
||||
try:
|
||||
entry = repl.conn.get_entries(
|
||||
DN(('cn', 'config')), ldap.SCOPE_SUBTREE, filter)
|
||||
except errors.NotFound:
|
||||
root_logger.error("Unable to find %s -> %s replication agreement" % (options.fromhost, thishost))
|
||||
sys.exit(1)
|
||||
if len(entry) > 1:
|
||||
|
||||
@@ -332,15 +332,15 @@ def get_ruv(realm, host, dirman_passwd):
|
||||
|
||||
search_filter = '(&(nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff)(objectclass=nstombstone))'
|
||||
try:
|
||||
entries = thisrepl.conn.search_s(api.env.basedn, ldap.SCOPE_ONELEVEL,
|
||||
search_filter, ['nsds50ruv'])
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
entries = thisrepl.conn.get_entries(
|
||||
api.env.basedn, ldap.SCOPE_ONELEVEL, search_filter, ['nsds50ruv'])
|
||||
except errors.NotFound:
|
||||
print "No RUV records found."
|
||||
sys.exit(0)
|
||||
|
||||
servers = []
|
||||
for e in entries:
|
||||
for ruv in e[1]['nsds50ruv']:
|
||||
for ruv in e['nsds50ruv']:
|
||||
if ruv.startswith('{replicageneration'):
|
||||
continue
|
||||
data = re.match('\{replica (\d+) (ldap://.*:\d+)\}(\s+\w+\s+\w*){0,1}', ruv)
|
||||
|
||||
@@ -704,9 +704,10 @@ class ADTRUSTInstance(service.Service):
|
||||
def find_local_id_range(self):
|
||||
self.ldap_connect()
|
||||
|
||||
if self.admin_conn.search_s(DN(api.env.container_ranges, self.suffix),
|
||||
ldap.SCOPE_ONELEVEL,
|
||||
"objectclass=ipaDomainIDRange"):
|
||||
if self.admin_conn.get_entries(
|
||||
DN(api.env.container_ranges, self.suffix),
|
||||
ldap.SCOPE_ONELEVEL,
|
||||
"(objectclass=ipaDomainIDRange)"):
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -727,8 +728,8 @@ class ADTRUSTInstance(service.Service):
|
||||
"(gidNumber<=%d)(gidNumner>=%d)))" % \
|
||||
((base_id - 1), (base_id + id_range_size),
|
||||
(base_id - 1), (base_id + id_range_size))
|
||||
if self.admin_conn.search_s("cn=accounts," + self.suffix,
|
||||
ldap.SCOPE_SUBTREE, id_filter):
|
||||
if self.admin_conn.get_entries(DN(('cn', 'accounts'), self.suffix),
|
||||
ldap.SCOPE_SUBTREE, id_filter):
|
||||
raise ValueError("There are objects with IDs out of the expected" \
|
||||
"range.\nAdd local ID range manually and try " \
|
||||
"again!")
|
||||
|
||||
@@ -167,8 +167,8 @@ def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None
|
||||
"""
|
||||
assert isinstance(dn, DN)
|
||||
try:
|
||||
conn.search_ext_s(dn, ldap.SCOPE_BASE)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
conn.get_entry(dn)
|
||||
except errors.NotFound:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
@@ -258,9 +258,10 @@ class KrbInstance(service.Service):
|
||||
# they may conflict.
|
||||
|
||||
try:
|
||||
res = self.admin_conn.search_s(DN(('cn', 'mapping'), ('cn', 'sasl'), ('cn', 'config')),
|
||||
ldap.SCOPE_ONELEVEL,
|
||||
"(objectclass=nsSaslMapping)")
|
||||
res = self.admin_conn.get_entries(
|
||||
DN(('cn', 'mapping'), ('cn', 'sasl'), ('cn', 'config')),
|
||||
ldap.SCOPE_ONELEVEL,
|
||||
"(objectclass=nsSaslMapping)")
|
||||
for r in res:
|
||||
try:
|
||||
self.admin_conn.delete_entry(r)
|
||||
|
||||
@@ -674,12 +674,14 @@ class ReplicationManager(object):
|
||||
while (retries > 0 ):
|
||||
root_logger.info('Getting ldap service principals for conversion: %s and %s' % (filter_a, filter_b))
|
||||
try:
|
||||
a_entry = b.search_s(self.suffix, ldap.SCOPE_SUBTREE, filterstr=filter_a)
|
||||
a_entry = b.get_entries(self.suffix, ldap.SCOPE_SUBTREE,
|
||||
filter=filter_a)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
|
||||
try:
|
||||
b_entry = a.search_s(self.suffix, ldap.SCOPE_SUBTREE, filterstr=filter_b)
|
||||
b_entry = a.get_entries(self.suffix, ldap.SCOPE_SUBTREE,
|
||||
filter=filter_b)
|
||||
except errors.NotFound:
|
||||
pass
|
||||
|
||||
|
||||
@@ -1704,10 +1704,6 @@ class IPAdmin(LDAPClient):
|
||||
# FIXME: for backwards compatibility only
|
||||
return self.conn.unbind_s(*args, **kwargs)
|
||||
|
||||
def search_s(self, *args, **kwargs):
|
||||
# FIXME: for backwards compatibility only
|
||||
return self.conn.search_s(*args, **kwargs)
|
||||
|
||||
def set_option(self, *args, **kwargs):
|
||||
# FIXME: for backwards compatibility only
|
||||
return self.conn.set_option(*args, **kwargs)
|
||||
@@ -1732,10 +1728,6 @@ class IPAdmin(LDAPClient):
|
||||
# FIXME: for backwards compatibility only
|
||||
return self.conn.start_tls_s(*args, **kwargs)
|
||||
|
||||
def search_ext_s(self, *args, **kwargs):
|
||||
# FIXME: for backwards compatibility only
|
||||
return self.conn.search_ext_s(*args, **kwargs)
|
||||
|
||||
|
||||
# FIXME: Some installer tools depend on ipaldap importing plugins.ldap2.
|
||||
# The proper plugins should rather be imported explicitly.
|
||||
|
||||
Reference in New Issue
Block a user