diff options
author | rcritten@redhat.com <rcritten@redhat.com> | 2007-10-02 16:56:51 -0400 |
---|---|---|
committer | rcritten@redhat.com <rcritten@redhat.com> | 2007-10-02 16:56:51 -0400 |
commit | 6aa72b44e42ac02487d5dcd08a67940e10dd1ac6 (patch) | |
tree | 4f0421e3a761e0d7eb77db32260990394a0b6aa0 /ipa-admintools/ipa-groupmod | |
parent | cfac4acf9fb152d685e342bd5adabb5ec2fa2c74 (diff) | |
download | freeipa-6aa72b44e42ac02487d5dcd08a67940e10dd1ac6.tar.gz freeipa-6aa72b44e42ac02487d5dcd08a67940e10dd1ac6.tar.xz freeipa-6aa72b44e42ac02487d5dcd08a67940e10dd1ac6.zip |
Do group operations based on the group DN, not the CN
Add new class of errors for connections
Raise an exception if a connection cannot be made due to missing ccache
Diffstat (limited to 'ipa-admintools/ipa-groupmod')
-rw-r--r-- | ipa-admintools/ipa-groupmod | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/ipa-admintools/ipa-groupmod b/ipa-admintools/ipa-groupmod index f3de92637..e0e953077 100644 --- a/ipa-admintools/ipa-groupmod +++ b/ipa-admintools/ipa-groupmod @@ -54,6 +54,15 @@ def parse_options(): return options, args +def get_group(client, group_cn): + try: + group = client.get_group_by_cn(group_cn) + except ipa.ipaerror.IPAError, e: + print "%s" % e.message + return None + + return group + def main(): group=ipa.group.Group() options, args = parse_options() @@ -66,16 +75,20 @@ def main(): try: client = ipaclient.IPAClient() if options.add: - client.add_user_to_group(args[1], args[2]) + group = get_group(client, args[2]) + if group is None: + return 1 + client.add_user_to_group(args[1], group.dn) print args[1] + " successfully added to " + args[2] elif options.remove: - client.remove_user_from_group(args[1], args[2]) + group = get_group(client, args[2]) + if group is None: + return 1 + client.remove_user_from_group(args[1], group.dn) print args[1] + " successfully removed" elif options.desc: - try: - group = client.get_group_by_cn(args[1]) - except ipa.ipaerror.IPAError, e: - print "%s" % e.message + group = get_group(client, args[1]) + if group is None: return 1 group.setValue('description', options.desc) client.update_group(group) |