Skip to content
Snippets Groups Projects
Commit fa63b4ac authored by Julian's avatar Julian
Browse files

Fixed relationship set and objectClass attribute handling for session.add

parent 9a0699fb
No related branches found
No related tags found
No related merge requests found
......@@ -60,12 +60,14 @@ class AddOperation:
def apply_object(self, obj_state):
obj_state.dn = self.dn
obj_state.attributes = {name: values.copy() for name, values in self.attributes.items()}
obj_state.attributes['objectClass'] = obj_state.attributes.get('objectClass', []) + list(self.object_classes)
def apply_session(self, session_state):
assert self.dn not in session_state.objects
session_state.objects[self.dn] = self.obj
for name, values in self.attributes.items():
session_state.ref(self.obj, name, values)
session_state.ref(self.obj, 'objectClass', self.object_classes)
def apply_ldap(self, conn):
success = conn.add(self.dn, self.object_classes, self.attributes)
......
......@@ -28,7 +28,7 @@ class RelationshipSet(MutableSet):
def __iter__(self):
def get(dn):
return make_modelobj(self.__ldap_object.session.get(dn, self.__model.ldap_filter_params), self.__destmodel)
return make_modelobj(self.__ldap_object.session.get(dn, self.__destmodel.ldap_filter_params), self.__destmodel)
dns = set(self.__ldap_object.getattr(self.__name))
return iter(filter(lambda obj: obj is not None, map(get, dns)))
......
......@@ -105,11 +105,11 @@ def csvimport():
if not newuser.set_mail(row[1]):
flash("invalid mail address, skipped : {}".format(row))
continue
ldap.session.add(newuser)
for role in roles:
if (str(role.id) in row[2].split(';')) or role.name in current_app.config["ROLES_BASEROLES"]:
role.members.add(newuser)
newuser.update_groups()
ldap.session.add(newuser)
try:
ldap.session.commit()
db.session.commit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment