summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/ldapupdate.py31
-rw-r--r--ipaserver/ipaldap.py12
2 files changed, 37 insertions, 6 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index f08ee8b9..0d260640 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -33,6 +33,7 @@ import pwd
import fnmatch
import csv
import inspect
+import copy
import krbV
import ldap
@@ -40,13 +41,37 @@ from ldap.schema.models import ObjectClass, AttributeType
from ipaserver.install import installutils
from ipaserver import ipaldap
-from ipapython import entity, ipautil
+from ipapython import ipautil
from ipalib import errors
from ipalib import api
from ipapython.dn import DN
from ipapython.ipa_log_manager import *
from ipaserver.install.plugins import PRE_UPDATE, POST_UPDATE
+
+class Entity(ipaldap.Entry):
+ # TODO: Use ldap2 instead
+ def __init__(self, entrydata=None):
+ ipaldap.Entry.__init__(self, entrydata)
+ y = {}
+ for key, value in self.data.iteritems():
+ y[copy.deepcopy(key)] = copy.deepcopy(value)
+ self.orig_data = ipautil.CIDict(y)
+
+ def attrList(self):
+ """Return a list of all attributes in the entry"""
+ return self.data.keys()
+
+ def origDataDict(self):
+ """Returns a dict of the original values of the user.
+
+ Used for updates.
+ """
+ result = ipautil.CIDict(self.orig_data)
+ result['dn'] = self.dn
+ return result
+
+
class BadSyntax(installutils.ScriptError):
def __init__(self, value):
self.value = value
@@ -255,7 +280,7 @@ class LDAPUpdate:
entry[key] = ''
elif len(value) == 1:
entry[key] = value[0]
- return entity.Entity(entry)
+ return Entity(entry)
def _combine_updates(self, all_updates, update):
'Combine a new update with the list of total updates'
@@ -483,7 +508,7 @@ class LDAPUpdate:
def _create_default_entry(self, dn, default):
"""Create the default entry from the values provided.
- The return type is entity.Entity
+ The return type is Entity
"""
assert isinstance(dn, DN)
entry = ipaldap.Entry(dn)
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py
index f44c4842..c64cd92b 100644
--- a/ipaserver/ipaldap.py
+++ b/ipaserver/ipaldap.py
@@ -38,7 +38,6 @@ from ipapython import ipautil
from ipalib import errors
from ipapython.ipautil import format_netloc, wait_for_open_socket, wait_for_open_ports
from ipapython.dn import DN
-from ipapython.entity import Entity
from ipaserver.plugins.ldap2 import IPASimpleLDAPObject, LDAPEntry
# Global variable to define SASL auth
@@ -113,6 +112,12 @@ class Entry:
elif isinstance(entrydata, basestring):
self.dn = DN(entrydata)
self.data = ipautil.CIDict()
+ elif isinstance(entrydata, dict):
+ if hasattr(entrydata, 'dn'):
+ entrydata['dn'] = entrydata.dn
+ self.dn = entrydata['dn']
+ del entrydata['dn']
+ self.data = ipautil.CIDict(entrydata)
else:
raise TypeError("entrydata must be 2-tuple, DN, or basestring, got %s" % type(entrydata))
else:
@@ -205,6 +210,7 @@ class Entry:
ldif.LDIFWriter(sio,Entry.base64_attrs,1000).unparse(str(self.dn),newdata)
return sio.getvalue()
+
class IPAdmin(IPAEntryLDAPObject):
def __localinit(self):
@@ -437,8 +443,8 @@ class IPAdmin(IPAEntryLDAPObject):
"""This wraps the add function. It assumes that the entry is already
populated with all of the desired objectclasses and attributes"""
- if not isinstance(entry, (Entry, Entity)):
- raise TypeError('addEntry expected an Entry or Entity object, got %s instead' % entry.__class__)
+ if not isinstance(entry, Entry):
+ raise TypeError('addEntry expected an Entry object, got %s instead' % entry.__class__)
sctrl = self.__get_server_controls()