summaryrefslogtreecommitdiffstats
path: root/ipa-admintools/ipa-finduser
diff options
context:
space:
mode:
Diffstat (limited to 'ipa-admintools/ipa-finduser')
-rw-r--r--ipa-admintools/ipa-finduser33
1 files changed, 12 insertions, 21 deletions
diff --git a/ipa-admintools/ipa-finduser b/ipa-admintools/ipa-finduser
index 919c4b92c..75df9493f 100644
--- a/ipa-admintools/ipa-finduser
+++ b/ipa-admintools/ipa-finduser
@@ -41,25 +41,22 @@ error was:
""" % sys.exc_value
sys.exit(1)
-def usage():
- print "ipa-finduser [-a|--all] [-n|--notranslate] [-v|--verbose] user"
- sys.exit()
-
def parse_options():
- parser = OptionParser()
+ usage = "%prog [-a|--all] [-n|--notranslate] [-v|--verbose] user"
+ parser = OptionParser(usage=usage)
parser.add_option("-a", "--all", action="store_true", dest="all",
help="Display all attributes")
parser.add_option("-n", "--notranslate", action="store_true",
dest="notranslate",
help="Don't translate LDAP attributes into readable labels")
- parser.add_option("--usage", action="store_true",
- help="Program usage")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
help="Verbose output of the XML-RPC connection")
- args = ipa.config.init_config(sys.argv)
- options, args = parser.parse_args(args)
+ ipa.config.add_standard_options(parser)
+ options, args = parser.parse_args()
+ ipa.config.verify_args(parser, args, "user")
+ ipa.config.init_config(options)
return options, args
@@ -88,20 +85,17 @@ def main():
user={}
options, args = parse_options()
- if options.usage or len(args) != 2:
- usage()
-
client = ipaclient.IPAClient(verbose=options.verbose)
if options.all is None:
- users = client.find_users(args[1], sattrs=['uid','givenname','sn','homeDirectory','loginshell'])
+ users = client.find_users(args[0], sattrs=['uid','givenname','sn','homeDirectory','loginshell'])
else:
- users = client.find_users(args[1], sattrs=None)
+ users = client.find_users(args[0], sattrs=None)
counter = users[0]
users = users[1:]
userindex = 0
if counter == 0:
- print "No entries found for", args[1]
+ print "No entries found for", args[0]
return 2
elif counter == -1:
print "These results are truncated."
@@ -125,11 +119,8 @@ def main():
# Always have sn following givenname
try:
l = attr.index('givenname')
- try:
- attr.remove('sn')
- attr.insert(l+1, 'sn')
- except ValueError:
- pass
+ attr.remove('sn')
+ attr.insert(l+1, 'sn')
except ValueError:
pass
@@ -152,7 +143,7 @@ def main():
for l in value:
print "\t" + wrap_binary_data(l)
# blank line between results
- print
+ print
return 0