mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Implement some of IPAdmin's legacy methods in terms of LDAPConnection methods
These will serve as templates for changes in the calling code. Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
This commit is contained in:
parent
a7a81238a8
commit
d9b3c91d47
@ -1651,60 +1651,34 @@ class IPAdmin(LDAPConnection):
|
|||||||
self.__bind_with_wait(self.sasl_interactive_bind_s, timeout, None, auth_tokens)
|
self.__bind_with_wait(self.sasl_interactive_bind_s, timeout, None, auth_tokens)
|
||||||
self.__lateinit()
|
self.__lateinit()
|
||||||
|
|
||||||
def getEntry(self, base, scope, filterstr='(objectClass=*)', attrlist=None, attrsonly=0):
|
def getEntry(self, base, scope, filterstr='(objectClass=*)',
|
||||||
"""This wraps the search function. It is common to just get one entry"""
|
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]
|
||||||
|
|
||||||
try:
|
def getList(self, base, scope, filterstr='(objectClass=*)', attrlist=None):
|
||||||
res = self.search(base, scope, filterstr, attrlist, attrsonly)
|
# FIXME: for backwards compatibility only
|
||||||
objtype, obj = self.result(res)
|
result, truncated = self.find_entries(
|
||||||
except ldap.LDAPError, e:
|
filter=filterstr,
|
||||||
arg_desc = 'base="%s", scope=%s, filterstr="%s"' % (base, scope, filterstr)
|
attrs_list=attrlist,
|
||||||
self.__handle_errors(e, arg_desc=arg_desc)
|
base_dn=base,
|
||||||
|
scope=scope,
|
||||||
if not obj:
|
)
|
||||||
arg_desc = 'base="%s", scope=%s, filterstr="%s"' % (base, scope, filterstr)
|
return result
|
||||||
raise errors.NotFound(reason=arg_desc)
|
|
||||||
|
|
||||||
elif isinstance(obj,Entry):
|
|
||||||
return obj
|
|
||||||
else: # assume list/tuple
|
|
||||||
return obj[0]
|
|
||||||
|
|
||||||
def getList(self, base, scope, filterstr='(objectClass=*)', attrlist=None, attrsonly=0):
|
|
||||||
"""This wraps the search function to find multiple entries."""
|
|
||||||
|
|
||||||
try:
|
|
||||||
res = self.search(base, scope, filterstr, attrlist, attrsonly)
|
|
||||||
objtype, obj = self.result(res)
|
|
||||||
except ldap.LDAPError, e:
|
|
||||||
arg_desc = 'base="%s", scope=%s, filterstr="%s"' % (base, scope, filterstr)
|
|
||||||
self.__handle_errors(e, arg_desc=arg_desc)
|
|
||||||
|
|
||||||
if not obj:
|
|
||||||
arg_desc = 'base="%s", scope=%s, filterstr="%s"' % (base, scope, filterstr)
|
|
||||||
raise errors.NotFound(reason=arg_desc)
|
|
||||||
|
|
||||||
entries = []
|
|
||||||
for s in obj:
|
|
||||||
entries.append(s)
|
|
||||||
|
|
||||||
return entries
|
|
||||||
|
|
||||||
def addEntry(self, entry):
|
def addEntry(self, entry):
|
||||||
"""This wraps the add function. It assumes that the entry is already
|
# FIXME: for backwards compatibility only
|
||||||
populated with all of the desired objectclasses and attributes"""
|
self.add_entry(entry.dn, entry)
|
||||||
|
|
||||||
if not isinstance(entry, Entry):
|
|
||||||
raise TypeError('addEntry expected an Entry object, got %s instead' % entry.__class__)
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.add_s(entry.dn, entry.toTupleList())
|
|
||||||
except ldap.LDAPError, e:
|
|
||||||
arg_desc = 'entry=%s: %s' % (entry.dn, entry.toTupleList())
|
|
||||||
self.__handle_errors(e, arg_desc=arg_desc)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def updateEntry(self,dn,oldentry,newentry):
|
def updateEntry(self,dn,oldentry,newentry):
|
||||||
|
# FIXME: for backwards compatibility only
|
||||||
"""This wraps the mod function. It assumes that the entry is already
|
"""This wraps the mod function. It assumes that the entry is already
|
||||||
populated with all of the desired objectclasses and attributes"""
|
populated with all of the desired objectclasses and attributes"""
|
||||||
|
|
||||||
@ -1722,6 +1696,7 @@ class IPAdmin(LDAPConnection):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def generateModList(self, old_entry, new_entry):
|
def generateModList(self, old_entry, new_entry):
|
||||||
|
# FIXME: for backwards compatibility only
|
||||||
"""A mod list generator that computes more precise modification lists
|
"""A mod list generator that computes more precise modification lists
|
||||||
than the python-ldap version. For single-value attributes always
|
than the python-ldap version. For single-value attributes always
|
||||||
use a REPLACE operation, otherwise use ADD/DEL.
|
use a REPLACE operation, otherwise use ADD/DEL.
|
||||||
@ -1802,15 +1777,8 @@ class IPAdmin(LDAPConnection):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def deleteEntry(self, dn):
|
def deleteEntry(self, dn):
|
||||||
"""This wraps the delete function. Use with caution."""
|
# FIXME: for backwards compatibility only
|
||||||
|
self.delete_entry(dn)
|
||||||
assert isinstance(dn, DN)
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.delete_s(dn)
|
|
||||||
except ldap.LDAPError, e:
|
|
||||||
arg_desc = 'dn=%s' % (dn)
|
|
||||||
self.__handle_errors(e, arg_desc=arg_desc)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def waitForEntry(self, dn, timeout=7200, attr='', quiet=True):
|
def waitForEntry(self, dn, timeout=7200, attr='', quiet=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user