第 10 章 Searching IdM entries using the ldapsearch command
You can use the ipa find command to search through the Identity Management entries. For more information about ipa command see Structure of IPA commands section in the Accessing Identity Management services documentation.
This section introduces the basics of an alternative search option using ldapsearch command line command through the Identity Management entries.
10.1. Using the ldapsearch command 复制链接链接已复制到粘贴板!
The ldapsearch command has the following format:
# ldapsearch [-x | -Y mechanism] [options] [search_filter] [list_of_attributes]
-
To configure the authentication method, specify the
-xoption to use simple binds or the-Yoption to set the Simple Authentication and Security Layer (SASL) mechanism. Note that you need to obtain a Kerberos ticket if you are using the-Y GSSAPIoption. -
The options are the
ldapsearchcommand options described in a table below. - The search_filter is an LDAP search filter.
- The list_of_attributes is a list of the attributes that the search results return.
For example, you want to search all the entries of a base LDAP tree for the user name user01:
# ldapsearch -x -H ldap://ldap.example.com -s sub "(uid=user01)"
-
The
-xoption tells theldapsearchcommand to authenticate with the simple bind. Note that if you do not provide the Distinguish Name (DN) with the-Doption, the authentication is anonymous. -
The
-Hoption connects you to the ldap://ldap.example.com. -
The
-s suboption tells theldapsearchcommand to search all the entries, starting from the base DN, for the user with the name user01. The "(uid=user01)" is a filter.
Note that if you do not provide the starting point for the search with the -b option, the command searches in the default tree. It is specified in the BASE parameter of the etc/openldap/ldap.conf file.
| Option | Description |
|---|---|
| -b |
The starting point for the search. If your search parameters contain an asterisk (*) or other character, that the command line can interpret into a code, you must wrap the value in single or double quotation marks. For example, |
| -D | The Distinguished Name (DN) with which you want to authenticate. |
| -H |
An LDAP URL to connect to the server. The |
| -l | The time limit in seconds to wait for a search request to complete. |
| -s scope | The scope of the search. You can choose one of the following for the scope:
|
| -W | Requests for the password. |
| -x | Disables the default SASL connection to allow simple binds. |
| -Y SASL_mechanism | Sets the SASL mechanism for the authentication. |
| -z number | The maximum number of entries in the search result. |
Note, you must specify one of the authentication mechanisms with the -x or -Y option with the ldapsearch command.