Manage append and replace User modify.
This commit is contained in:
parent
79d7dcc653
commit
ec472218c4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user