diff options
author | Rob Crittenden <rcritten@redhat.com> | 2007-11-15 14:20:50 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2007-11-15 14:20:50 -0500 |
commit | 49aa82e932ccce69dca1170db6f1838904350222 (patch) | |
tree | 7b82f8369118b1d7dc67e6c151476f0c28222b49 | |
parent | 3e24df161b6f3b4946cf702aa780008069161406 (diff) | |
download | freeipa-49aa82e932ccce69dca1170db6f1838904350222.tar.gz freeipa-49aa82e932ccce69dca1170db6f1838904350222.tar.xz freeipa-49aa82e932ccce69dca1170db6f1838904350222.zip |
Use same labels as UI for ipa-finduser and ipa-findgroup
Add -a option to ipa-findgroup to print all attributes
-rw-r--r-- | ipa-admintools/ipa-findgroup | 21 | ||||
-rw-r--r-- | ipa-admintools/ipa-finduser | 13 |
2 files changed, 29 insertions, 5 deletions
diff --git a/ipa-admintools/ipa-findgroup b/ipa-admintools/ipa-findgroup index 6953d4fd3..9f809aa0b 100644 --- a/ipa-admintools/ipa-findgroup +++ b/ipa-admintools/ipa-findgroup @@ -35,6 +35,12 @@ def usage(): def parse_options(): parser = OptionParser() + parser.add_option("-a", "--all", action="store_true", dest="all", + help="Show all group attributes") + parser.add_option("-n", "--notranslate", action="store_true", + dest="notranslate", + help="Don't translate LDAP attributes into readable labels") + args = ipa.config.init_config(sys.argv) options, args = parser.parse_args(args) @@ -49,7 +55,10 @@ def main(): try: client = ipaclient.IPAClient() - groups = client.find_groups(args[1], ['cn','description','gidnumber']) + if options.all is None: + groups = client.find_groups(args[1], ['cn','description','gidnumber','nsAccountLock']) + else: + groups = client.find_groups(args[1], sattrs=['*','nsAccountLock']) counter = groups[0] groups = groups[1:] @@ -65,15 +74,21 @@ def main(): print str(e) continue attr = ent.attrList() + if options.notranslate: + labels = {} + for a in attr: + labels[a] = a + else: + labels = client.attrs_to_labels(attr) print "dn: " + ent.dn for a in attr: value = ent.getValues(a) if isinstance(value,str): - print a + ": " + value + print labels[a] + ": " + value else: - print a + ": " + print labels[a] + ": " for l in value: print "\t" + l diff --git a/ipa-admintools/ipa-finduser b/ipa-admintools/ipa-finduser index a6f052f1d..6dc4d56c8 100644 --- a/ipa-admintools/ipa-finduser +++ b/ipa-admintools/ipa-finduser @@ -39,6 +39,9 @@ def parse_options(): parser.add_option("-a", "--all", action="store_true", dest="all", help="Set user's e-mail address") + 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") @@ -91,6 +94,12 @@ def main(): for ent in users: attr = ent.attrList() attr.sort() + if options.notranslate: + labels = {} + for a in attr: + labels[a] = a + else: + labels = client.attrs_to_labels(attr) if options.all is True: print "dn: " + ent.dn @@ -98,9 +107,9 @@ def main(): for a in attr: value = ent.getValues(a) if isinstance(value,str): - print a + ": " + str(wrap_binary_data(value)).rstrip() + print labels[a] + ": " + str(wrap_binary_data(value)).rstrip() else: - print a + ": " + print labels[a] + ": " for l in value: print "\t" + wrap_binary_data(l) # blank line between results |