MCPcopy Index your code
hub / github.com/XiaoliChan/LDAPShell / do_add_user_to_group

Method do_add_user_to_group

utils/ldap_shell.py:277–295  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

275 print('Adding new user with username: %s and password: %s result: OK' % (new_user, new_password))
276
277 def do_add_user_to_group(self, line):
278 user_name, group_name = shlex.split(line)
279
280 user_dn = self.get_dn(user_name)
281 if not user_dn:
282 raise Exception("User not found in LDAP: %s" % user_name)
283
284 group_dn = self.get_dn(group_name)
285 if not group_dn:
286 raise Exception("Group not found in LDAP: %s" % group_name)
287
288 user_name = user_dn.split(',')[0][3:]
289 group_name = group_dn.split(',')[0][3:]
290
291 res = self.client.modify(group_dn, {'member': [(ldap3.MODIFY_ADD, [user_dn])]})
292 if res:
293 print('Adding user: %s to group %s result: OK' % (user_name, group_name))
294 else:
295 raise Exception('Failed to add user to %s group: %s' % (group_name, str(self.client.result['description'])))
296
297 def do_change_password(self, line):
298 args = shlex.split(line)

Callers

nothing calls this directly

Calls 1

get_dnMethod · 0.95

Tested by

no test coverage detected