Creates an update_entry api call, aliases update_user and update_group to it.

This commit is contained in:
Kevin McCarthy
2007-10-15 09:04:13 -07:00
parent 63f7cdf7f7
commit fbbdd27b53
5 changed files with 28 additions and 8 deletions

View File

@@ -78,6 +78,12 @@ class IPAClient:
result = self.transport.get_entry_by_cn(cn,sattrs)
return entity.Entity(result)
def update_entry(self,entry):
"""Update a entry."""
result = self.transport.update_entry(entry.origDataDict(), entry.toDict())
return result
# User support
def get_user_by_uid(self,uid,sattrs=None):
"""Get a specific user by uid. If sattrs is set then only those

View File

@@ -118,6 +118,20 @@ class RPCClient:
return ipautil.unwrap_binary_data(result)
def update_entry(self,oldentry,newentry):
"""Update an existing entry. oldentry and newentry are dicts of attributes"""
server = self.setup_server()
try:
result = server.update_entry(ipautil.wrap_binary_data(oldentry),
ipautil.wrap_binary_data(newentry))
except xmlrpclib.Fault, fault:
raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
except socket.error, (value, msg):
raise xmlrpclib.Fault(value, msg)
return ipautil.unwrap_binary_data(result)
# User support

View File

@@ -62,8 +62,7 @@ class DelegationController(IPAController):
aci_entry = client.get_aci_entry(['dn'])
aci_entry.setValue('aci', new_aci.export_to_string())
# TODO - add a client.update_entry() call instead
client.update_group(aci_entry)
client.update_entry(aci_entry)
except ipaerror.IPAError, e:
turbogears.flash("Delgate add failed: " + str(e))
return dict(form=delegate_new_form, delegate=kw,

View File

@@ -343,6 +343,10 @@ class IPAServer:
filter = "(cn=" + cn + ")"
return self.__get_sub_entry(self.basedn, filter, sattrs, opts)
def update_entry (self, oldentry, newentry, opts=None):
"""Update an entry in LDAP"""
return self.__update_entry(oldentry, newentry, opts)
# User support
def __is_user_unique(self, uid, opts):
@@ -586,9 +590,7 @@ class IPAServer:
return new_dict
def update_user (self, olduser, newuser, opts=None):
"""Update a user in LDAP"""
return self.__update_entry(olduser, newuser, opts)
update_user = update_entry
def mark_user_deleted (self, uid, opts=None):
"""Mark a user as inactive in LDAP. We aren't actually deleting
@@ -987,9 +989,7 @@ class IPAServer:
return failed
def update_group (self, oldgroup, newgroup, opts=None):
"""Update a group in LDAP"""
return self.__update_entry(oldgroup, newgroup, opts)
update_group = update_entry
def delete_group (self, group_dn, opts=None):
"""Delete a group

View File

@@ -320,6 +320,7 @@ def handler(req, profiling=False):
h.register_function(f.get_aci_entry)
h.register_function(f.get_entry_by_dn)
h.register_function(f.get_entry_by_cn)
h.register_function(f.update_entry)
h.register_function(f.get_user_by_uid)
h.register_function(f.get_user_by_principal)
h.register_function(f.get_users_by_manager)