ldapsearch cmdline question
Rick Stevens
ricks at nerd.com
Fri Sep 25 19:16:58 UTC 2009
bruce wrote:
> Hi..
>
> Trying to run a simple ldap search/query against a supposedly public ldap
> server. I've tried a number of copy/paste attempts that I've seen from
> various sites with no luck...
>
> If anyone has successfully pinged/queried a public ldap server from the
> cmdline, can you post your cmd that you used so I can see what I'm missing..
>
> the site www.emailman.com/ldap/public lists a number of public ldap servers.
> i'm simply trying to figure out how to query/access the names from one of
> the ldap servers.
>
> as an example, i tried to use:
> ldapsearch -x -h ldap.bu.edu -b "dc=bu,dc=edu" "(sn=tom*)"
> (but this generates a ldap_bind: protocol error...
>
> however, if i do:
> ldapsearch -x -h stanford.edu -b "dc=stanford,dc=edu" "(sn=tom*)"
> or
> ldapsearch -x -h usc.edu -b "dc=usc,dc=edu" "(sn=tom*)"
> then i get back a list of data...
>
> also, the bu.edu for boston university, works on the website...
>
> so, i'm sure i'm missing something simple, but i can't pin it down. any
> help/pointers would be 'ppreciated!
>
> my goal is to be able to understand how to query a public ldap server and to
> be able to return different data elements.. (ie, name, given, first, or
> email/phone/etc..)
See my response to David Timms. Try "-P 2" on the command line. Fedora
(and most distros) use newer LDAP clients that default to LDAP V3. The
"bu.edu" server is defaulting to LDAP V2 (and should be upgraded). The
"-P 2" option forces LDAP V2 protocol.
The "(sn=tom*)" is an LDAP filter. Your second command essentially
means "find me any entries whose surnames start with 'tom' ('sn' means
'surname') in the tree starting at 'stanford.edu' ('dc=stanford,dc=edu')
and return all attributes." If you only want specific attributes
returned, then place them after the filter, separated by commas:
ldapsearch -x -h stanford.edu -b "dc=stanford,dc=edu" "(sn=tom*)"
"gn,sn,cn,description"
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer ricks at nerd.com -
- AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 -
- -
- Errors have occurred. We won't tell you where or why. We have -
- lazy programmers. -
----------------------------------------------------------------------
More information about the fedora-list
mailing list