Manage append and replace User modify.

refactor
blallo 2019-07-06 21:24:26 +02:00
parent 79d7dcc653
commit ec472218c4
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
1 changed files with 12 additions and 2 deletions

View File

@ -272,10 +272,16 @@ class User(Hackers):
if not k == "dn":
self._entry[k] = v
async def modify(self, key, value):
async def modify(self, key, value, append=False):
async with self.client.connect(is_async=True) as conn:
self._entry.connection = conn
await self._entry.change_attribute(key, LDAPModOp.REPLACE, value)
try:
if not append:
del self._entry[key]
self._entry[key] = value
except KeyError:
raise PhiAttributeMissing
await self._entry.modify()
async def remove(self):
async with self.client.connect(is_async=True) as conn:
@ -291,6 +297,10 @@ class PhiUserDoesNotExist(Exception):
pass
class PhiAttributeMissing(Exception):
pass
class Service(Robots):
"""
This class models a system user (i.e. users that are ancillary to