summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-08 12:34:11 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-04-08 12:34:11 (GMT)
commit07ef012ce1660979b53b8b383c19444f164bf50b (patch)
tree913be5979c917da7bf163397dc4ba151e39dd673
parent1e8c12a01a6be9a0b4b48ebbfb13048a6d11f3bd (diff)
downloadpykolab-07ef012ce1660979b53b8b383c19444f164bf50b.tar.gz
Correct adding back in an attribute
-rw-r--r--pykolab/auth/ldap/__init__.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index ae06a5f..2213f39 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -854,6 +854,9 @@ class LDAP(object):
attribute = attribute.lower()
+ if not user.has_key(attribute):
+ user[attribute] = self._get_user_attribute(user, attribute)
+
mode = None
# TODO: This should be a schema check!
@@ -875,18 +878,17 @@ class LDAP(object):
user['objectclass']
)
- if not user.has_key(attribute):
- mode = ldap.MOD_ADD
-
- if mode == None:
+ if user.has_key(attribute) and not user[attribute] == None:
mode = ldap.MOD_REPLACE
+ else:
+ mode = ldap.MOD_ADD
try:
- self.ldap.modify(user['dn'], [(mode, attribute, value)])
- except:
+ self.ldap.modify(user['dn'], [(mode, attribute, '%s' % (value))])
+ except ldap.LDAPError, e:
log.warning(
_("LDAP modification of attribute %s for %s to value " + \
- "%s failed") % (attribute,user_dn,value)
+ "%s failed: %r") % (attribute,user_dn,value,e.message['info'])
)
def _list_domains(self):