From 5f0f23ee91d51b2a45206ce7d9ddc413d3fa9670 Mon Sep 17 00:00:00 2001 From: "rcritten@redhat.com" Date: Tue, 14 Aug 2007 17:22:05 -0400 Subject: Ensure that the Apache server is in forked mode Add ability to update existing users Try to prevent fetching and setting empty strings --- ipa-server/ipaserver/ipaldap.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ipa-server/ipaserver/ipaldap.py') diff --git a/ipa-server/ipaserver/ipaldap.py b/ipa-server/ipaserver/ipaldap.py index 7268594a..08113b4c 100644 --- a/ipa-server/ipaserver/ipaldap.py +++ b/ipa-server/ipaserver/ipaldap.py @@ -35,6 +35,7 @@ import time import operator import struct from ldap.controls import LDAPControl,DecodeControlTuples,EncodeControlTuples +from ldap.modlist import modifyModlist from ldap.ldapobject import SimpleLDAPObject @@ -307,6 +308,25 @@ class IPAdmin(SimpleLDAPObject): raise e return "Success" + def updateEntry(self,dn,olduser,newuser): + """This wraps the mod function. It assumes that the entry is already + populated with all of the desired objectclasses and attributes""" + + sctrl = self.__get_server_controls__() + + # find the differences but don't remove attributes that are missing + # from the update + modlist = modifyModlist(olduser, newuser, None, 1) + + try: + self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl) + self.modify_s(dn, modlist) + except ldap.ALREADY_EXISTS: + raise ldap.ALREADY_EXISTS + except ldap.LDAPError, e: + raise e + return "Success" + def __wrapmethods(self): """This wraps all methods of SimpleLDAPObject, so that we can intercept the methods that deal with entries. Instead of using a raw list of tuples -- cgit