[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ldapsearch output



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tobias Rice wrote:
| Is there a way to have ldapsearch return a single value? I'd like to
| give it a uid name and have it just return the uidNumber. If I enter this:
| ldapsearch -x "(uid=hsimpson)" uidNumber
| # extended LDIF
| #
| # LDAPv3
| # base <> with scope sub
| # filter: (uid=hsimpson)
| # requesting: uidNumber
| #
|
| # hsimpson, People, aorganise.com
| dn: uid=hsimpson,ou=People,dc=mydomain,dc=com
| uidNumber: 1012
|
| # search result
| search: 2
| result: 0 Success
|
| # numResponses: 2
| # numEntries: 1
|
| ...I'm getting way to much back for my scripts.
|
| All I want is 1012. Is there a better way to filter this or will I have
| to do it elsewhere (like perl)?
|

How about:

ldapsearch -x "(uid=hsimpson)" uidNumber -LLL|awk -F ': ' '/^uidNumber/
{print $1}'
- --
Buchan Milne                      Senior Support Technician
Obsidian Systems                  http://www.obsidian.co.za
B.Eng                                RHCE (803004789010797)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAs6OCrJK6UGDSBKcRAiI4AJ9KlwfKnzLC7ujg1WzPXaQmma61mQCdF27s
dd4kvhGLpjBJet8EenEfKNU=
=OgzR
-----END PGP SIGNATURE-----