Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using ldapsearch to return only a value

Tags:

linux

openldap

using an OPENLDAP server i want to retrieve informations from it with ldapsearch. I created a custom class called iduriclass, this class is used to store an id and an uri. in my ldapsearch command i want it to return only the uri for a specified id.

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

Trying it i get an ldif file that contains all uris in the server

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

like image 615
Reda Avatar asked Jan 01 '14 12:01

Reda


People also ask

What is ldapsearch command used for?

ldapsearch is a command-line tool that opens a connection to an LDAP server, binds to it, and performs a search using a filter. The results are then displayed in the LDIF. The LDIF is used to represent LDAP entries in a simple text format.

How do I use ldapsearch?

To search for the LDAP configuration, use the “ldapsearch” command and specify “cn=config” as the search base for your LDAP tree. To run this search, you have to use the “-Y” option and specify “EXTERNAL” as the authentication mechanism.

What port does ldapsearch use?

The default LDAPS port is 636.

What is ldapsearch Linux?

ldapsearch is a shell-accessible interface to the ldap_search_ext(3) library call. ldapsearch opens a connection to an LDAP server, binds, and performs a search using specified parameters. The filter should conform to the string representation for search filters as defined in RFC 4515.


1 Answers

Adding the parameter -tt writes a file with ONLY the requested attribute(s) value as the OP requested. No preceding field name or anything else. Path is configurable with -T, otherwise is /tmp

I write this clarification due to lack of reputation to comment.

like image 97
badc0de Avatar answered Sep 21 '22 13:09

badc0de