diff options
author | Karl MacMillan <kmacmillan@mentalrootkit.com> | 2007-07-30 17:46:26 -0400 |
---|---|---|
committer | Karl MacMillan <kmacmillan@mentalrootkit.com> | 2007-07-30 17:46:26 -0400 |
commit | 1d8d4222ab05ee7cf84203d4917174f7fbca1200 (patch) | |
tree | 9c588daf024de77c755ab337f42af3c3da789f69 /ipa-admintools | |
parent | 4d656111e6eb035ef06eeb1a9b10ed33a095adc5 (diff) | |
download | freeipa-1d8d4222ab05ee7cf84203d4917174f7fbca1200.tar.gz freeipa-1d8d4222ab05ee7cf84203d4917174f7fbca1200.tar.xz freeipa-1d8d4222ab05ee7cf84203d4917174f7fbca1200.zip |
Second (final) part of xmlrpc patch.
Diffstat (limited to 'ipa-admintools')
-rw-r--r-- | ipa-admintools/Makefile | 7 | ||||
-rw-r--r-- | ipa-admintools/src/Makefile | 10 | ||||
-rw-r--r-- | ipa-admintools/src/ipa-adduser | 80 | ||||
-rw-r--r-- | ipa-admintools/src/ipa-finduser | 58 |
4 files changed, 153 insertions, 2 deletions
diff --git a/ipa-admintools/Makefile b/ipa-admintools/Makefile index 8005c0b49..a7b276f2b 100644 --- a/ipa-admintools/Makefile +++ b/ipa-admintools/Makefile @@ -1,5 +1,8 @@ -all: +all: ; install: + $(MAKE) -C src $@ -clean:
\ No newline at end of file +clean: + $(MAKE) -C src $@ + rm -f *~ diff --git a/ipa-admintools/src/Makefile b/ipa-admintools/src/Makefile new file mode 100644 index 000000000..e0fd405ab --- /dev/null +++ b/ipa-admintools/src/Makefile @@ -0,0 +1,10 @@ +SBINDIR = $(DESTDIR)/usr/sbin + +all: ; + +install: + install -m 755 ipa-adduser $(SBINDIR) + install -m 755 ipa-finduser $(SBINDIR) + +clean: + rm -f *~ *.pyc diff --git a/ipa-admintools/src/ipa-adduser b/ipa-admintools/src/ipa-adduser new file mode 100644 index 000000000..94a19dba4 --- /dev/null +++ b/ipa-admintools/src/ipa-adduser @@ -0,0 +1,80 @@ +#! /usr/bin/python -E +# Authors: Rob Crittenden <rcritten@redhat.com> +# +# 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.rpcclient +import xmlrpclib + +def usage(): + print "ipa-adduser [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] user" + sys.exit(1) + +def parse_options(): + parser = OptionParser() + parser.add_option("-c", "--gecos", dest="gecos", + help="Set the GECOS field") + parser.add_option("-d", "--directory", dest="directory", + help="Set the User's home directory") + parser.add_option("-f", "--firstname", dest="gn", + help="User's first name") + parser.add_option("-l", "--lastname", dest="sn", + help="User's last name") + parser.add_option("-s", "--shell", dest="shell", + help="Set user's login shell to shell") + parser.add_option("--usage", action="store_true", + help="Program usage") + + (options, args) = parser.parse_args() + + if not options.gn or not options.sn: + usage() + + return options, args + +def main(): + user={} + (options, args) = parse_options() + + if len(args) != 1: + usage() + + user['gn'] = options.gn + user['sn'] = options.sn + user['uid'] = args[0] + if options.gecos: + user['gecos'] = options.gecos + if options.directory: + user['homedirectory'] = options.directory + if options.shell: + user['loginshell'] = options.shell + else + user['loginshell'] = "/bin/bash" + + try: + ipa.rpcclient.add_user(user) + print args[0] "successfully added" + except xmlrpclib.Fault, f: + print f.faultString + + return 0 + +main()
\ No newline at end of file diff --git a/ipa-admintools/src/ipa-finduser b/ipa-admintools/src/ipa-finduser new file mode 100644 index 000000000..928eff753 --- /dev/null +++ b/ipa-admintools/src/ipa-finduser @@ -0,0 +1,58 @@ +#! /usr/bin/python -E +# Authors: Rob Crittenden <rcritten@redhat.com> +# +# 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 +# + +from optparse import OptionParser +import ipa +import ipa.rpcclient +import ipa.ipaldap +import base64 +import sys +import xmlrpclib + +def usage(): + print "ipa-finduser <uid>" + sys.exit() + +def parse_options(): + parser = OptionParser() + + (options, args) = parser.parse_args() + + return options, args + +def main(): + user={} + (options, args) = parse_options() + + if len(args) != 1: + usage() + + try: + ent = ipa.rpcclient.get_user(args[0]) + entry = ipa.ipaldap.Entry(ent['dn']) + for e in ent: + entry.setValues(e, ent[e]) + print entry + except xmlrpclib.Fault, fault: + print fault.faultString + + return 0 + +main()
\ No newline at end of file |