.ldaprc - Linux


Overview

.ldaprc is a configuration file for the OpenLDAP client libraries. It specifies connection parameters, security settings, and other options for LDAP operations. This file is typically located in the user’s home directory or system-wide configuration directory.

Syntax

$HOME/.ldaprc

Options/Flags

TLS-related options:

  • TLS_REQCERT: Specify the TLS certificate verification level.
  • TLS_CACERTDIR: Directory containing TLS CA certificates.
  • TLS_CERT: Client certificate file for TLS authentication.
  • TLS_KEY: Client key file for TLS authentication.

Connection settings:

  • HOST: LDAP server hostname or IP address.
  • PORT: LDAP server port number.
  • BASE: Default base DN for LDAP searches.

Security options:

  • AUTH_METHOD: Authentication method (e.g., simple, bind, anonymous).
  • AUTH_CRED: Authentication credentials (e.g., username:password).

Other options:

  • TIMELIMIT: Default LDAP operation timeout in seconds.
  • SIZELIMIT: Default number of search results to return.
  • DEBUG: Enable debugging output.
  • URI: Use LDAP URI syntax to specify the LDAP server.

Examples

Simple configuration

HOST=ldap.example.com
PORT=389
AUTH_METHOD=simple
AUTH_CRED=uid=admin,cn=users,dc=example,dc=com

TLS-enabled configuration

HOST=ldap.example.com
PORT=636
TLS_REQCERT=demand
TLS_CACERTDIR=/etc/ssl/certs
TLS_CERT=/etc/ldap/client.crt
TLS_KEY=/etc/ldap/client.key

Common Issues

  • Connection failures: Ensure the LDAP server is running and the HOST and PORT settings are correct.
  • Authentication errors: Check the AUTH_METHOD and AUTH_CRED settings for typos or incorrect credentials.
  • TLS certificate errors: Verify that the TLS_CACERTDIR, TLS_CERT, and TLS_KEY files are valid and accessible.

Integration

.ldaprc can be used with other tools like ldapsearch and ldapmodify to perform various LDAP operations. For instance:

ldapsearch -H ldap.example.com -b dc=example,dc=com -s sub "(objectClass=*)"

Related Commands

  • ldapsearch: Search LDAP directories.
  • ldapmodify: Modify LDAP directory entries.
  • ldappasswd: Change LDAP passwords.