Using ldapsearch to return only value

using the OPENLDAP server , I want to get information from it ldapsearch . I created my own class called iduriclass , this class is used to store identifier and uri. in my ldapsearch command, I want it to return only uri for the specified id.

EXAMPLE: the directory now contains two entries id=test uri=server.com/testandid=test2 uri=server.com/test2

Trying to get ldif file containing all uris on server

I want to have the ldapsearch command, which takes test as an argument and returns only a value that: server.com/test

+4
source share
2 answers

ldap.

HOSTNAME=<your ladap hostname>
USERNAME=<your ldap username>
PASSWORD=<your ldap username password>
SEARCHBASE=<your ldap search base DN>
QUERYSTRING=test1
PORT=<your ldap port>

ldapsearch -LLL -h ${HOSTNAME} -p $PORT -D cn=${USERNAME} -w ${PASSWORD} -b "${SEARCHBASE}" "(id=${QUERYSTRING})" uri | sed -n 's/^[ \t]*uri:[ \t]*\(.*\)/\1/p'

-LLL ldap . ldap -x ( ), SASL.

+10

-tt () OP. - . -T, /tmp

- .

-1

All Articles