summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2013-12-10 11:56:35 +0100
committerPetr Viktorin <pviktori@redhat.com>2014-01-10 14:41:40 +0100
commitf7128b9c03eadb9593be9b781cf5c9a34b9e10bc (patch)
tree4dbd2dbe25df33b2cc6cbf4ead231d0aa822fd03
parentc86d9f33c9b54ff705b029f72c3b45de530155b1 (diff)
downloadfreeipa-f7128b9c03eadb9593be9b781cf5c9a34b9e10bc.tar.gz
freeipa-f7128b9c03eadb9593be9b781cf5c9a34b9e10bc.tar.xz
freeipa-f7128b9c03eadb9593be9b781cf5c9a34b9e10bc.zip
Use raw LDAP data in ldapupdate.
https://fedorahosted.org/freeipa/ticket/3488
-rw-r--r--ipaserver/install/ldapupdate.py30
1 files changed, 7 insertions, 23 deletions
diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index 94a1fed0..a9167aee 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -50,9 +50,9 @@ from ipaserver.plugins import ldap2
def connect(ldapi=False, realm=None, fqdn=None, dm_password=None, pw_name=None):
"""Create a connection for updates"""
if ldapi:
- conn = ipaldap.IPAdmin(ldapi=True, realm=realm)
+ conn = ipaldap.IPAdmin(ldapi=True, realm=realm, decode_attrs=False)
else:
- conn = ipaldap.IPAdmin(fqdn, ldapi=False, realm=realm)
+ conn = ipaldap.IPAdmin(fqdn, ldapi=False, realm=realm, decode_attrs=False)
try:
if dm_password:
conn.do_simple_bind(binddn=DN(('cn', 'directory manager')),
@@ -235,8 +235,7 @@ class LDAPUpdate:
skipinitialspace=True,
**kwargs)
for row in csv_reader:
- # decode UTF-8 back to Unicode, cell by cell:
- yield [unicode(cell, 'utf-8') for cell in row]
+ yield row
def _identify_arch(self):
"""On multi-arch systems some libraries may be in /lib64, /usr/lib64,
@@ -557,19 +556,7 @@ class LDAPUpdate:
# We already do syntax-parsing so this is safe
(action, attr, update_values) = update.split(':',2)
update_values = self._parse_values(update_values)
-
- # If the attribute is known to be a DN convert it to a DN object.
- # This has to be done after _parse_values() due to quoting and comma separated lists.
- if self.conn.has_dn_syntax(attr):
- update_values = [DN(x) for x in update_values]
-
- entry_values = entry.get(attr)
- if not isinstance(entry_values, list):
- if entry_values is None:
- entry_values = []
- else:
- entry_values = [entry_values]
-
+ entry_values = entry.get(attr, [])
for update_value in update_values:
if action == 'remove':
self.debug("remove: '%s' from %s, current value %s", safe_output(attr, update_value), attr, safe_output(attr,entry_values))
@@ -646,12 +633,9 @@ class LDAPUpdate:
self.debug("%s", message)
self.debug("dn: %s", e.dn)
for a, value in e.items():
- if isinstance(value, (list, tuple)):
- self.debug('%s:', a)
- for l in value:
- self.debug("\t%s", safe_output(a, l))
- else:
- self.debug('%s: %s', a, safe_output(a, value))
+ self.debug('%s:', a)
+ for l in value:
+ self.debug("\t%s", safe_output(a, l))
def _update_record(self, update):
found = False