diff options
author | Marc Muehlfeld <mmuehlfeld@samba.org> | 2014-10-18 00:34:35 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-10-23 18:19:35 +0200 |
commit | 4bec1867987845fc40e9a17a283d2affc36e0dc5 (patch) | |
tree | e85947119e0f47aa0c46039ea3ad771e55860893 /python/samba/netcmd/group.py | |
parent | 4ab6df622c81363b8acb31113016ecfbbe1ec5c4 (diff) | |
download | samba-4bec1867987845fc40e9a17a283d2affc36e0dc5.tar.gz samba-4bec1867987845fc40e9a17a283d2affc36e0dc5.tar.xz samba-4bec1867987845fc40e9a17a283d2affc36e0dc5.zip |
samba-tool group add: Add option --nis-domain and --gid
This allows creating RFC2307 enabled groups via samba-tool
Signed-off-by: Marc Muehlfeld <mmuehlfeld@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Oct 23 18:19:35 CEST 2014 on sn-devel-104
Diffstat (limited to 'python/samba/netcmd/group.py')
-rw-r--r-- | python/samba/netcmd/group.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 1a24e5f0fa..4b5fd27d79 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -70,6 +70,11 @@ Example2: sudo samba-tool group add Group2 --group-type=Distribution Example2 adds a new distribution group to the local server. The command is run under root using the sudo command. + +Example3: +samba-tool group add Group3 --nis-domain=samdom --gid=12345 + +Example3 adds a new RFC2307 enabled group for NIS domain samdom and GID 12345 (both options are required to enable this feature). """ synopsis = "%prog <groupname> [options]" @@ -93,19 +98,24 @@ Example2 adds a new distribution group to the local server. The command is run Option("--description", help="Group's description", type=str), Option("--mail-address", help="Group's email address", type=str), Option("--notes", help="Groups's notes", type=str), + Option("--gid-number", help="Group's Unix/RFC2307 GID number", type=int), + Option("--nis-domain", help="SFU30 NIS Domain", type=str), ] takes_args = ["groupname"] def run(self, groupname, credopts=None, sambaopts=None, versionopts=None, H=None, groupou=None, group_scope=None, - group_type=None, description=None, mail_address=None, notes=None): + group_type=None, description=None, mail_address=None, notes=None, gid_number=None, nis_domain=None): if (group_type or "Security") == "Security": gtype = security_group.get(group_scope, GTYPE_SECURITY_GLOBAL_GROUP) else: gtype = distribution_group.get(group_scope, GTYPE_DISTRIBUTION_GLOBAL_GROUP) + if (gid_number is None and nis_domain is not None) or (gid_number is not None and nis_domain is None): + raise CommandError('Both --gid-number and --nis-domain have to be set for a RFC2307-enabled group. Operation cancelled.') + lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) @@ -113,7 +123,8 @@ Example2 adds a new distribution group to the local server. The command is run samdb = SamDB(url=H, session_info=system_session(), credentials=creds, lp=lp) samdb.newgroup(groupname, groupou=groupou, grouptype = gtype, - description=description, mailaddress=mail_address, notes=notes) + description=description, mailaddress=mail_address, notes=notes, + gidnumber=gid_number, nisdomain=nis_domain) except Exception, e: # FIXME: catch more specific exception raise CommandError('Failed to create group "%s"' % groupname, e) |