[Freeipa-devel] [RFC] show first/last name in ipa-finduser output
Rob Crittenden
rcritten at redhat.com
Fri Jul 25 19:19:51 UTC 2008
We currently display common name in ipa-finduser which can cause
confusion since we explicitly provide options for managing first and
last name. Updating those doesn't automatically update the cn field so
it looks as if a change hasn't been applied.
So here is my first crack at fixing it. All I've done is grab sn and
givenname instead of cn and ensure that in the display sn comes after
gn. It looks like:
% ipa-finduser tuser1
First Name: Testy
Last Name: User
Home Directory: /home/tuser1
Login Shell: /bin/sh
Login: tuser1
% ipa-finduser -a tuser1 |grep Full
Full Name: Test User
So you can see that the Full Name (cn) isn't the same as givenname + sn.
I wanted to avoid creating some sort of special "full name" attribute
because one can run this with -n to get the real LDAP attribute names
and I didn't want anyone trying to query for LDAP attributes that don't
exist.
So here is a patch for the current approach. Need some feedback.
diff --git a/ipa-admintools/ipa-finduser b/ipa-admintools/ipa-finduser
index 40384a3..de0e6fc 100644
--- a/ipa-admintools/ipa-finduser
+++ b/ipa-admintools/ipa-finduser
@@ -93,7 +93,7 @@ def main():
client = ipaclient.IPAClient(verbose=options.verbose)
if options.all is None:
- users = client.find_users(args[1],
sattrs=['uid','cn','homeDirectory','
loginshell'])
+ users = client.find_users(args[1],
sattrs=['uid','givenname','sn','home
Directory','loginshell'])
else:
users = client.find_users(args[1], sattrs=None)
@@ -121,6 +121,18 @@ def main():
for ent in users:
attr = ent.attrList()
attr.sort()
+
+ # Always have sn following givenname
+ try:
+ l = attr.index('givenname')
+ try:
+ attr.remove('sn')
+ except:
+ pass
+ attr.insert(l+1, 'sn')
+ except:
+ pass
+
if options.notranslate:
labels = {}
for a in attr:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20080725/cb0fb0e3/attachment.bin>
More information about the Freeipa-devel
mailing list