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

Re: ldapsearch output



On Tue, 25 May 2004, Tobias Rice wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 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

You can tell ldapsearch to eliminate comments and the LDIF version
string by using the -LLL option. This would leave you with:

> dn: uid=hsimpson,ou=People,dc=mydomain,dc=com
> uidNumber: 1012

The rest will need filtering by you.

Off topic alternative: If you are using nss_ldap on the same computer
where you are doing the query, and if the entry whose uidNumber is
sought is available to your name services, you could use a call to
getpwnam(3) and friends to get the uidNumber. Hint: perldoc -f getpwnam.

-- 
Kirk Turner-Rustin
Programmer/Analyst
Libraries and Information Services
Ohio Wesleyan University
http://www.owu.edu