diff options
author | Karl MacMillan <kmacmillan@mentalrootkit.com> | 2007-07-31 12:09:38 -0400 |
---|---|---|
committer | Karl MacMillan <kmacmillan@mentalrootkit.com> | 2007-07-31 12:09:38 -0400 |
commit | 7d95cd612c1b340add692038c835e7cd8d8ad18b (patch) | |
tree | 144813760c6ff19d85285496293270385af74fde /ipa-admintools/ipa-adduser | |
parent | 1d8d4222ab05ee7cf84203d4917174f7fbca1200 (diff) | |
download | freeipa-7d95cd612c1b340add692038c835e7cd8d8ad18b.tar.gz freeipa-7d95cd612c1b340add692038c835e7cd8d8ad18b.tar.xz freeipa-7d95cd612c1b340add692038c835e7cd8d8ad18b.zip |
Final reorginzation to reflect packaging.
Diffstat (limited to 'ipa-admintools/ipa-adduser')
-rw-r--r-- | ipa-admintools/ipa-adduser | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/ipa-admintools/ipa-adduser b/ipa-admintools/ipa-adduser new file mode 100644 index 000000000..94a19dba4 --- /dev/null +++ b/ipa-admintools/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 |