|
|
|
@ -1,5 +1,4 @@ |
|
|
|
|
import json |
|
|
|
|
import traceback |
|
|
|
|
from typing import List, Union |
|
|
|
|
|
|
|
|
|
import ldap3 |
|
|
|
@ -92,8 +91,8 @@ class Group: |
|
|
|
|
try: |
|
|
|
|
with self.ldap_srv.entry_ctx_for_group(self) as entry: |
|
|
|
|
entry.uniqueMember.add(dn) |
|
|
|
|
except ldap3.core.exceptions.LDAPAttributeOrValueExistsResult: |
|
|
|
|
logger.error(traceback.format_exc()) |
|
|
|
|
except ldap3.core.exceptions.LDAPAttributeOrValueExistsResult as err: |
|
|
|
|
logger.warning(err) |
|
|
|
|
raise UserAlreadyInGroupError() |
|
|
|
|
self.members.append(username) |
|
|
|
|
|
|
|
|
@ -102,7 +101,7 @@ class Group: |
|
|
|
|
try: |
|
|
|
|
with self.ldap_srv.entry_ctx_for_group(self) as entry: |
|
|
|
|
entry.uniqueMember.delete(dn) |
|
|
|
|
except ldap3.core.exceptions.LDAPCursorError: |
|
|
|
|
logger.error(traceback.format_exc()) |
|
|
|
|
except ldap3.core.exceptions.LDAPCursorError as err: |
|
|
|
|
logger.warning(err) |
|
|
|
|
raise UserNotInGroupError() |
|
|
|
|
self.members.remove(username) |
|
|
|
|