diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-03-30 23:10:34 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-03-30 23:10:34 +0100 |
commit | 62a409cb43b441c32692f414a1867176d37034ac (patch) | |
tree | 50c70342106c2674d61b5559f7dfa89dc1f506bc /utils/nslcd.py | |
parent | aae36cfcfb6ec00776f6da1e0d1fd5f90a72f2dd (diff) | |
parent | 012b18554e5e6a408a11a7157a30c5d068f2d3d1 (diff) |
Implement used modification functionality
This adds user information modification functionality to nslcd and pynslcd and
implements a chsh.ldap utility that can be used to change the login shell of a
user (similar to the normal chsh command).
The user modification functionality should allow for generic modifications of
user information. More utility commands to perform modifications remain to be
implemented.
Diffstat (limited to 'utils/nslcd.py')
-rw-r--r-- | utils/nslcd.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/utils/nslcd.py b/utils/nslcd.py index 06165cc..65e5822 100644 --- a/utils/nslcd.py +++ b/utils/nslcd.py @@ -111,3 +111,26 @@ class NslcdClient(object): def __del__(self): self.close() + + +def usermod(username, asroot=False, password=None, args=None): + # open a connection to nslcd + con = NslcdClient(constants.NSLCD_ACTION_USERMOD) + # write the request information + con.write_string(username) + con.write_int32(1 if asroot else 0) + con.write_string(password) + for k, v in args.items(): + con.write_int32(k) + con.write_string(v) + con.write_int32(constants.NSLCD_USERMOD_END) + # read the response + assert con.get_response() == constants.NSLCD_RESULT_BEGIN + response = {} + while True: + key = con.read_int32() + if key == constants.NSLCD_USERMOD_END: + break + response[key] = con.read_string() + # return the response + return response |