2.2. $HOME/.alias Example

Command aliases can be used to select a given configuration file and to preselect certain command line options. Below is a list of some common command line options.

-x

Use simple authentication instead of SASL.

-W

Prompt for password.

-LLL

-L restricts the output to LDIFv1. -LL disables comments. -LLL disables printing of the LDIF version.

-o ldif-wrap=no

Disable line wrapping.

-E pr=PAGESIZE/noprompt

Some LDAP server products (e.g., Microsoft Active Directory) implement a page results (pr) extension. On those servers, if this option is not provided, the results may be halted after some number of entries (e.g., 1000). A Size limit exceeded (4) will be displayed. If this option is provided with a reasonable PAGESIZE (e.g., 1000), then the server will continue to provide results, page-by-page. /noprompt can be replaced with /prompt, in which case you will be prompted each time to retrieve the next page.

Below are examples of aliases that could be added to a file like $HOME/.alias.

alias ldapsearch='ldapsearch -x -W -LLL -o ldif-wrap=no'
alias ldapsearch-foo='LDAPRC=~/.ldap.d/ldaprc-foo ldapsearch -x -W -LLL -o ldif-wrap=no'
alias ldapsearch-bar='LDAPRC=~/.ldap.d/ldaprc-bar ldapsearch -x -LLL -o ldif-wrap=no'

To make certain that these aliases are available automatically in new interactive non-login shells, file $HOME/.bashrc should contain code like that below.

if [ -f "$HOME/.alias" ]
then
    . "$HOME/.alias"
fi

And to make certain that $HOME/.bashrc is automatically sourced in new interactive login shells, file $HOME/.bash_profile should contain code like that below.

if [ -f "$HOME/.bashrc" ]
then
    . "$HOME/.bashrc"
fi