summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBjörn Baumbach <bb@sernet.de>2019-08-09 17:07:07 +0200
committerStefan Metzmacher <metze@samba.org>2020-01-21 14:38:46 +0000
commitf2e2579926e0bfcd8b150c33cd4784391426c5e6 (patch)
treede8bbf86baec221434ab01da2337762c20e7726b /python
parenta4d77bfd90d09b37b89f99042d9e0e3d5b102677 (diff)
downloadsamba-f2e2579926e0bfcd8b150c33cd4784391426c5e6.tar.gz
samba-tool group addmembers: add new option --object-types
With this option the admin can specify the object types of the group members which will be added to the group. The search filter for the objects will be created according to the types. Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/group.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py
index 2e1db1371b4..6a8da402c47 100644
--- a/python/samba/netcmd/group.py
+++ b/python/samba/netcmd/group.py
@@ -229,12 +229,27 @@ 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("--object-types",
+ help=("Comma separated list of object types.\n"
+ "The types are used to filter the search for the "
+ "specified members.\n"
+ "Valid values are: user, group, computer, serviceaccount, "
+ "contact and all.\n"
+ "Default: user,group,computer"),
+ default="user,group,computer",
+ type=str),
]
takes_args = ["groupname", "listofmembers"]
- def run(self, groupname, listofmembers, credopts=None, sambaopts=None,
- versionopts=None, H=None):
+ def run(self,
+ groupname,
+ listofmembers,
+ credopts=None,
+ sambaopts=None,
+ versionopts=None,
+ H=None,
+ object_types="user,group,computer"):
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp, fallback_machine=True)
@@ -243,8 +258,10 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro
samdb = SamDB(url=H, session_info=system_session(),
credentials=creds, lp=lp)
groupmembers = listofmembers.split(',')
+ group_member_types = object_types.split(',')
samdb.add_remove_group_members(groupname, groupmembers,
- add_members_operation=True)
+ add_members_operation=True,
+ member_types=group_member_types)
except Exception as e:
# FIXME: catch more specific exception
raise CommandError('Failed to add members "%s" to group "%s"' % (