diff options
author | Björn Baumbach <bb@sernet.de> | 2019-12-17 16:26:23 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2020-01-21 14:38:46 +0000 |
commit | aedcf6a52748d0858aab7d1b3e0253592e963706 (patch) | |
tree | 24a28cb89a974b22f1b5baa232847b15ba7e995d /python/samba/netcmd | |
parent | f2e2579926e0bfcd8b150c33cd4784391426c5e6 (diff) | |
download | samba-aedcf6a52748d0858aab7d1b3e0253592e963706.tar.gz |
samba-tool group addmembers: add --member-dn option
The --member-dn option allows to specify an object by it's DN.
This is required to select a specific object if there are more than one
with the same name. Multiple contacts can exist with the same name in
different OUs.
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'python/samba/netcmd')
-rw-r--r-- | python/samba/netcmd/group.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 6a8da402c47..4bf417cc878 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -218,7 +218,7 @@ sudo samba-tool group addmembers supergroup User2 Example2 shows how to add a single user account, User2, to the supergroup AD group. It uses the sudo command to run as root when issuing the command. """ - synopsis = "%prog <groupname> <listofmembers> [options]" + synopsis = "%prog <groupname> (<listofmembers>]|--member-dn=<member-dn>) [options]" takes_optiongroups = { "sambaopts": options.SambaOptions, @@ -229,6 +229,10 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro takes_options = [ Option("-H", "--URL", help="LDB URL for database or target server", type=str, metavar="URL", dest="H"), + Option("--member-dn", + help=("DN of the new group member to be added.\n" + "The --object-types option will be ignored."), + type=str), Option("--object-types", help=("Comma separated list of object types.\n" "The types are used to filter the search for the " @@ -240,15 +244,16 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro type=str), ] - takes_args = ["groupname", "listofmembers"] + takes_args = ["groupname", "listofmembers?"] def run(self, groupname, - listofmembers, + listofmembers=None, credopts=None, sambaopts=None, versionopts=None, H=None, + member_dn=None, object_types="user,group,computer"): lp = sambaopts.get_loadparm() @@ -257,7 +262,10 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro try: samdb = SamDB(url=H, session_info=system_session(), credentials=creds, lp=lp) - groupmembers = listofmembers.split(',') + if member_dn is not None: + groupmembers = [ member_dn ] + else: + groupmembers = listofmembers.split(',') group_member_types = object_types.split(',') samdb.add_remove_group_members(groupname, groupmembers, add_members_operation=True, |