To perform LDAP queries on Scientific Linux, you'll need the ldapsearch
utility, which is part of the openldap-clients
package. Scientific Linux, being a RHEL-derived distribution, uses the same package management system as CentOS and RHEL.
There are two primary ways to install ldapsearch
on Scientific Linux:
# Method 1: Using yum (recommended for Scientific Linux 6)
sudo yum install openldap-clients
# Method 2: Using dnf (for Scientific Linux 7+)
sudo dnf install openldap-clients
After installation, verify that ldapsearch
is available:
which ldapsearch
ldapsearch -V
Here are some practical examples of using ldapsearch
:
# Simple anonymous query
ldapsearch -x -H ldap://ldap.example.com -b "dc=example,dc=com"
# Authenticated query
ldapsearch -x -H ldap://ldap.example.com -D "cn=admin,dc=example,dc=com" -W -b "dc=example,dc=com"
# Specific attribute search
ldapsearch -x -H ldap://ldap.example.com -b "dc=example,dc=com" "(uid=johndoe)" cn mail
# Using SSL/TLS
ldapsearch -x -H ldaps://ldap.example.com -b "dc=example,dc=com" -ZZ
If you encounter problems, check these common solutions:
# If you get "No such file or directory" for ldapsearch:
sudo yum whatprovides */ldapsearch
# For SSL/TLS certificate issues:
export LDAPTLS_REQCERT=never
For frequent LDAP queries, consider creating a ~/.ldaprc
file:
BASE dc=example,dc=com
URI ldap://ldap.example.com
TLS_CACERT /etc/ssl/certs/ca-bundle.crt
This will save you from typing common parameters repeatedly.
If openldap-clients
isn't available in your repositories, you can try:
sudo yum install epel-release
sudo yum install openldap-clients
Or compile from source if necessary.
To perform LDAP queries on Scientific Linux, you'll need the ldapsearch
utility which is part of the OpenLDAP client package. Scientific Linux (being RHEL-based) typically includes this in its default repositories.
The most straightforward way to install ldapsearch is through yum (or dnf on newer versions):
sudo yum install openldap-clients
For systems with dnf package manager:
sudo dnf install openldap-clients
After installation, verify it works with a simple query:
ldapsearch -x -LLL -H ldap://ldap.example.com -b "dc=example,dc=com" "(objectclass=*)"
Common flags explanation:
-x
: Simple authentication-LLL
: Disable pretty-printing (machine-readable output)-H
: LDAP server URI-b
: Base DN for search
For frequent use, create an ~/.ldaprc
file with defaults:
BASE dc=example,dc=com URI ldap://ldap.example.com BINDDN cn=admin,dc=example,dc=com
If you get SSL errors, you may need to install certificates:
sudo yum install ca-certificates
For SASL authentication issues, install additional packages:
sudo yum install cyrus-sasl cyrus-sasl-gssapi
If the package isn't in your repositories, you can:
- Enable EPEL repository:
sudo yum install epel-release
- Compile from source:
wget https://www.openldap.org/software/download/OpenLDAP/openldap-release.tgz tar xzf openldap-release.tgz cd openldap-* ./configure --prefix=/usr/local make depend make sudo make install