diff --git a/ipa-admintools/ipa-delgroup b/ipa-admintools/ipa-delgroup new file mode 100644 index 000000000..50967a49b --- /dev/null +++ b/ipa-admintools/ipa-delgroup @@ -0,0 +1,69 @@ +#! /usr/bin/python -E +# Authors: Rob Crittenden +# +# Copyright (C) 2007 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 only +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +from optparse import OptionParser +import ipa +import ipa.ipaclient as ipaclient +import ipa.config + +import xmlrpclib +import kerberos + +def usage(): + print "ipa-delgroup group" + sys.exit(1) + +def parse_options(): + parser = OptionParser() + parser.add_option("--usage", action="store_true", + help="Program usage") + + args = ipa.config.init_config(sys.argv) + options, args = parser.parse_args(args) + + return options, args + +def main(): + options, args = parse_options() + + if len(args) != 2: + usage() + + try: + client = ipaclient.IPAClient() + ret = client.delete_group(args[1]) + if (ret == "Success"): + print args[1] + " successfully deleted" + else: + print args[1] + " " + ret + except xmlrpclib.Fault, f: + print f.faultString + return 1 + except kerberos.GSSError, e: + print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0]) + return 1 + except xmlrpclib.ProtocolError, e: + print "Unable to connect to IPA server: %s" % (e.errmsg) + return 1 + + return 0 + +main() diff --git a/ipa-admintools/ipa-deluser b/ipa-admintools/ipa-deluser index 10d248062..bcee2afd9 100644 --- a/ipa-admintools/ipa-deluser +++ b/ipa-admintools/ipa-deluser @@ -28,7 +28,7 @@ import xmlrpclib import kerberos def usage(): - print "ipa-adduser user" + print "ipa-deluser user" sys.exit(1) def parse_options(): diff --git a/ipa-admintools/ipa-groupmod b/ipa-admintools/ipa-groupmod index eea96b43a..f3de92637 100644 --- a/ipa-admintools/ipa-groupmod +++ b/ipa-admintools/ipa-groupmod @@ -58,7 +58,6 @@ def main(): group=ipa.group.Group() options, args = parse_options() - print "len = ", len(args) if (options.add or options.remove) and (len(args) != 3): usage() if (options.desc and (len(args) != 2)): @@ -68,7 +67,7 @@ def main(): client = ipaclient.IPAClient() if options.add: client.add_user_to_group(args[1], args[2]) - print args[1] + " successfully added" + print args[1] + " successfully added to " + args[2] elif options.remove: client.remove_user_from_group(args[1], args[2]) print args[1] + " successfully removed" diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py index 71def70fd..fcfb29f1d 100644 --- a/ipa-python/ipaclient.py +++ b/ipa-python/ipaclient.py @@ -94,12 +94,14 @@ class IPAClient: return result def find_users(self, criteria, sattrs=None): - """Find users whose uid matches the criteria. Wildcards are - acceptable. Returns a list of User objects.""" + """Return a list: counter followed by a User object for each user that + matches the criteria. If the results are truncated, counter will + be set to -1""" result = self.transport.find_users(criteria, sattrs) + counter = result[0] - users = [] - for attrs in result: + users = [counter] + for attrs in result[1:]: if attrs is not None: users.append(user.User(attrs)) @@ -113,6 +115,14 @@ class IPAClient: result = self.transport.update_user(user.origDataDict(), user.toDict()) return result + def delete_user(self,uid): + """Delete a user entry.""" + + realm = config.config.get_realm() + + result = self.transport.delete_user(uid) + return result + def mark_user_deleted(self,uid): """Set a user as inactive by uid.""" @@ -202,7 +212,17 @@ class IPAClient: def update_group(self,group): """Update a group entry.""" - realm = config.config.get_realm() + return self.transport.update_group(group.origDataDict(), group.toDict()) - result = self.transport.update_group(group.origDataDict(), group.toDict()) - return result + def delete_group(self,group_cn): + """Delete a group entry.""" + + return self.transport.delete_group(group_cn) + + def add_group_to_group(self, group_cn, tgroup_cn): + """Add a group to an existing group. + group_cn is a cn of the group to add + tgroup_cn is the cn of the group to be added to + """ + + return self.transport.add_group_to_group(group_cn, tgroup_cn) diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py index 74f7cfff6..be6b037fe 100644 --- a/ipa-python/ipautil.py +++ b/ipa-python/ipautil.py @@ -25,9 +25,10 @@ class CIDict(dict): """ Case-insensitive but case-respecting dictionary. - Idea from python-ldap cidict, however this version extends 'dict' - so it works properly with TurboGears. + This code is derived from python-ldap's cidict.py module, + written by stroeder: http://python-ldap.sourceforge.net/ + This version extends 'dict' so it works properly with TurboGears. If you extend UserDict, isinstance(foo, dict) returns false. """ diff --git a/ipa-python/rpcclient.py b/ipa-python/rpcclient.py index 3e5bb113a..e0d6e2ee7 100644 --- a/ipa-python/rpcclient.py +++ b/ipa-python/rpcclient.py @@ -151,8 +151,9 @@ class RPCClient: return ipautil.unwrap_binary_data(result) def find_users (self, criteria, sattrs=None): - """Return a list containing a User object for each user that matches - the criteria.""" + """Return a list: counter followed by a User object for each user that + matches the criteria. If the results are truncated, counter will + be set to -1""" server = self.setup_server() try: @@ -181,6 +182,19 @@ class RPCClient: return ipautil.unwrap_binary_data(result) + def delete_user(self,uid): + """Delete a user. uid is the uid of the user to delete.""" + server = self.setup_server() + + try: + result = server.delete_user(uid) + except xmlrpclib.Fault, fault: + raise ipaerror.gen_exception(fault.faultCode, fault.faultString) + except socket.error, (value, msg): + raise xmlrpclib.Fault(value, msg) + + return result + def mark_user_deleted(self,uid): """Mark a user as deleted/inactive""" server = self.setup_server() @@ -344,3 +358,31 @@ class RPCClient: raise xmlrpclib.Fault(value, msg) return ipautil.unwrap_binary_data(result) + + def delete_group(self,group_cn): + """Delete a group. group_cn is the cn of the group to be deleted.""" + server = self.setup_server() + + try: + result = server.delete_group(group_cn) + except xmlrpclib.Fault, fault: + raise ipaerror.gen_exception(fault.faultCode, fault.faultString) + except socket.error, (value, msg): + raise xmlrpclib.Fault(value, msg) + + return ipautil.unwrap_binary_data(result) + + def add_group_to_group(self, group_cn, tgroup_cn): + """Add a group to an existing group. + group_cn is a cn of the group to add + tgroup_cn is the cn of the group to be added to + """ + server = self.setup_server() + try: + result = server.add_group_to_group(group_cn, tgroup_cn) + except xmlrpclib.Fault, fault: + raise ipaerror.gen_exception(fault.faultCode, fault.faultString) + except socket.error, (value, msg): + raise xmlrpclib.Fault(value, msg) + + return ipautil.unwrap_binary_data(result) diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py index 7dff9c908..d767f2686 100644 --- a/ipa-server/ipa-gui/ipagui/controllers.py +++ b/ipa-server/ipa-gui/ipagui/controllers.py @@ -140,15 +140,21 @@ class Root(controllers.RootController): def userlist(self, **kw): """Retrieve a list of all users and display them in one huge list""" users = None + counter = 0 uid = kw.get('uid') if uid != None and len(uid) > 0: try: users = client.find_users(uid.encode('utf-8')) + counter = users[0] + users = users[1:] + if counter == -1: + turbogears.flash("These results are truncated.
" + + "Please refine your search and try again.") except ipaerror.IPAError, e: - turbogears.flash("User show failed: " + str(e)) + turbogears.flash("User list failed: " + str(e)) raise turbogears.redirect("/userlist") - return dict(users=users, fields=forms.user.UserFields()) + return dict(users=users, uid=uid, fields=forms.user.UserFields()) @expose("ipagui.templates.usershow") diff --git a/ipa-server/ipa-gui/ipagui/static/css/style.css b/ipa-server/ipa-gui/ipagui/static/css/style.css index b5bd82807..3c260c21b 100644 --- a/ipa-server/ipa-gui/ipagui/static/css/style.css +++ b/ipa-server/ipa-gui/ipagui/static/css/style.css @@ -33,7 +33,8 @@ body { #nav { background:#cc0000; color:#fff; - padding:5px; + min-height:3px; + max-height:3px; } #nav ul { @@ -58,15 +59,14 @@ body { background:#fff; float:right; width:85%; + min-height:500px; border-left: 1px solid #000; - padding-left: 15px; - padding-bottom: 15px; -/* color: black; - font-size: 127%; - background-color: white; - margin: 0 auto 0 auto; padding: 10px; - float: left; */ +} + +#main_content h1,h2 { + margin-top: 0px; + margin-bottom: 5px; } @@ -74,12 +74,8 @@ body { background:#ccc; /* should be same as #page */ float:left; width:10%; - /* border: 1px solid #aaa; - background-color: #eee; - margin: 0.5em; - padding: 1em; - float: left; - font-size: 88%; */ + padding: 5px; + font-size: small; } #sidebar h2 { @@ -91,17 +87,25 @@ body { padding-left: 0; } +#sidebar a:visited, +#sidebar a:link { + color:#000; +} + #footer { background:#fff; clear:both; border-top: 1px solid #000; - /* color: #999; - background-color: white; - padding: 10px; - font-size: 80%; + padding-top: 10px; text-align: center; - margin: 0 auto 1em auto; */ + font-size: x-small; +} + +#footer a:visited, +#footer a:link { + color:#777; + text-decoration: none; } @@ -129,26 +133,32 @@ body { #status_block { margin: 0 auto 0.5em auto; padding: 15px 10px 15px 55px; - background: #cec URL('../images/ok.png') left center no-repeat; - border: 1px solid #9c9; + background: #ecc; + border: 1px solid #c99; width: 450px; font-size: 120%; font-weight: bolder; } -.notice { - margin: 0.5em auto 0.5em auto; - padding: 15px 10px 15px 55px; - width: 450px; - background: #eef URL('../images/info.png') left center no-repeat; - border: 1px solid #cce; -} - .fielderror { - color: red; - font-weight: bold; + color: red; + font-weight: bold; } .requiredfield { - background: #eebbbb; + background: #eebbbb; +} + +#resultstable, +#resultstable th, +#resultstable td { + border-collapse: collapse; + border-style: solid; + border-width: 1px; + margin: 0px; + padding: 5px; +} + +#resultstable th { + background: #eee; } diff --git a/ipa-server/ipa-gui/ipagui/static/images/logo.png b/ipa-server/ipa-gui/ipagui/static/images/logo.png new file mode 100644 index 000000000..096c8813f Binary files /dev/null and b/ipa-server/ipa-gui/ipagui/static/images/logo.png differ diff --git a/ipa-server/ipa-gui/ipagui/templates/groupindex.kid b/ipa-server/ipa-gui/ipagui/templates/groupindex.kid index 0bb70ac9a..84a138468 100644 --- a/ipa-server/ipa-gui/ipagui/templates/groupindex.kid +++ b/ipa-server/ipa-gui/ipagui/templates/groupindex.kid @@ -7,12 +7,5 @@ Groups go here. -
-
-
-
-
-
-
diff --git a/ipa-server/ipa-gui/ipagui/templates/grouplayout.kid b/ipa-server/ipa-gui/ipagui/templates/grouplayout.kid index af05a8082..edaf716e9 100644 --- a/ipa-server/ipa-gui/ipagui/templates/grouplayout.kid +++ b/ipa-server/ipa-gui/ipagui/templates/grouplayout.kid @@ -6,17 +6,18 @@
-
+
-