Ensure that the Apache server is in forked mode
Add ability to update existing users Try to prevent fetching and setting empty strings
This commit is contained in:
1 parent
547f501fae
commit
5f0f23ee91
7 files changed
+188
-2
No files matched your search
@@ -96,3 +96,9 @@ class IPAClient:
|
||||
|
||||
return users
|
||||
|
||||
def update_user(self,olduser,newuser):
|
||||
|
||||
realm = config.config.get_realm()
|
||||
|
||||
result = self.transport.update_user(olduser,newuser)
|
||||
return result
|
||||
+14
-2
@@ -74,8 +74,7 @@ class RPCClient:
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def add_user(self,user):
|
||||
"""Add a new user"""
|
||||
server = self.setup_server()
|
||||
@@ -135,3 +134,16 @@ class RPCClient:
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return result
|
||||
|
||||
def update_user(self,olduser,newuser):
|
||||
"""Update an existing user. olduser and newuser are dicts of attributes"""
|
||||
server = self.setup_server()
|
||||
|
||||
try:
|
||||
result = server.update_user(olduser, newuser)
|
||||
except xmlrpclib.Fault, fault:
|
||||
raise xmlrpclib.Fault(fault.faultCode, fault.faultString)
|
||||
except socket.error, (value, msg):
|
||||
raise xmlrpclib.Fault(value, msg)
|
||||
|
||||
return result
|
||||
@@ -58,6 +58,8 @@ class User:
|
||||
def getValue(self,name):
|
||||
"""Get the first value for the attribute named name"""
|
||||
value = self.data.get(name,[None])
|
||||
if (len(value) < 1):
|
||||
return value
|
||||
if isinstance(value[0],list) or isinstance(value[0],tuple):
|
||||
return value[0]
|
||||
else:
|
||||
@@ -72,6 +74,8 @@ class User:
|
||||
ent.setValue('name', ('value1', 'value2', ..., 'valueN'))
|
||||
Since *value is a tuple, we may have to extract a list or tuple from that
|
||||
tuple as in the last two examples above"""
|
||||
if (len(value[0]) < 1):
|
||||
return
|
||||
if isinstance(value[0],list) or isinstance(value[0],tuple):
|
||||
self.data[name] = value[0]
|
||||
else:
|
||||
@@ -85,6 +89,15 @@ class User:
|
||||
single value or a list of values."""
|
||||
return self.data.items()
|
||||
|
||||
def toDict(self):
|
||||
"""Convert the attrs and values to a dict. The dict is keyed on the
|
||||
attribute name. The value is either single value or a list of values."""
|
||||
result = {}
|
||||
for k in self.data.keys():
|
||||
result[k] = self.data[k]
|
||||
result['dn'] = self.dn
|
||||
return result
|
||||
|
||||
def attrList(self):
|
||||
"""Return a list of all attributes in the entry"""
|
||||
return self.data.keys()
|
||||
|
||||
Reference in new issue
Block a user