Created
October 28, 2011 20:26
-
-
Save jblaine/1323448 to your computer and use it in GitHub Desktop.
Emulating ypcat passwd with ldapsearch + awk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ldapsearch \ | |
-h ldap1.our.org \ | |
-x \ | |
-LLL \ | |
-b ou=People,dc=rcf,dc=our,dc=org \ | |
'objectClass=posixAccount' | \ | |
awk -F': ' 'BEGIN {gecos=""; uid=""; uidnum=""; gidnum=""; home=""; shell="" | |
;} /^uid: / {uid=$2} /^gecos: / {gecos=$2} /^uidNumber: / {uidnum=$2} /^gidNumbe | |
r: / {gidnum=$2} /^loginShell: / {shell=$2} /^homeDirectory: / {home=$2} {if (ui | |
d != "" && uidnum != "" && gidnum != "") {print uid "::" uidnum ":" gidnum ":" g | |
ecos ":" home ":" shell; uid=""; gecos=""; uidnum=""; gidnum=""; home=""; shell= | |
"";} } END { print uid "::" uidnum ":" gidnum ":" gecos ":" home ":" shell; }' | |
# Now go scrub your eyes with a brush. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment