[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: ldapsearch output
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thank all for your suggestions!
This works great!
function getUidNum($user)
{
~~ $command = "ldapsearch -x -LLL \"(uid=$user)\" uidNumber \
~~ | awk '($1==\"uidNumber:\") { print $2 }'";
~~ $ldapString = trim(`$command`);
~~ return $ldapString;
}
Tobias
Buchan Milne wrote:
| 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.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFAs8hBRJX8S0T0CkURAtPoAKCv6CpMMXoHGYyiRrpJyOFvCtFVLQCgxsqM
pfREArqQxKkxryrRhHLLZik=
=Iswp
-----END PGP SIGNATURE-----