2.1. ldaprc Example

This section will provide an example of configuring LDAP clients.

To handle the case where you want to specify two or more configurations, create directory $HOME/.ldap.d.

mkdir $HOME/.ldap.d

Create a file $HOME/.ldap.d/ldaprc-foo with one configuration.

# ldaprc-foo

# http://www.openldap.org/software/man.cgi?query=ldap.conf&sektion=5&apropos=0&manpath=OpenLDAP+2.4-Release

# URIs for one or more LDAP servers;
# typical URI schemes are ldap (over TCP) or ldaps (over SSL);
# ldapsearch -H
URI         ldaps://foo.example.com

# default bind DN;
# this must be a distinguished name for an authorized user;
# ldapsearch -D
BINDDN      john_doe@foo.example.com

# default base DN;
# starting point in directory;
# ldapsearch -b
BASE        dc=foo,dc=example,dc=com

# size limit;
# 0 is unlimited;
# ldapsearch -z
SIZELIMIT   0

Create a file $HOME/.ldap.d/ldaprc-bar with a second configuration.

# ldaprc-bar

# http://www.openldap.org/software/man.cgi?query=ldap.conf&sektion=5&apropos=0&manpath=OpenLDAP+2.4-Release

# URIs for one or more LDAP servers;
# typical URI schemes are ldap (over TCP) or ldaps (over SSL);
# ldapsearch -H
URI         ldaps://bar.example.com

# default bind DN;
# this must be a distinguished name for an authorized user;
# ldapsearch -D
BINDDN      john_doe@bar.example.com

# default base DN;
# starting point in directory;
# ldapsearch -b
BASE        dc=bar,dc=example,dc=com

# size limit;
# 0 is unlimited;
# ldapsearch -z
SIZELIMIT   0

Let's say configuration ldaprc-foo will be used more frequently. Create a symbolic link $HOME/.ldaprc.

cd
ln -s .ldap.d/ldaprc-foo .ldaprc