LDAP Address Book Icon

LDAP Address Book

Web-based LDAP address book browser/editor

Contents

  1. Getting Started Using the Address Book
    1. Mozilla Firefox Search Integration
    2. Google Chrome/Chromium Search Integration
  2. Installation and Basic Setup
    1. Upgrading from Previous Versions
    2. Installation on Linux
      1. Apache HTTP Server on Ubuntu 12.04 and similar Debian derivatives
    3. Installation on Windows: Apache HTTP Server or Microsoft IIS
    4. Set up access to the directory service
    5. What is an LDAP distinguished name (DN)?
      1. DNs as shown in Active Directory Users and Computers
      2. DNs as shown in Novell iManager or ConsoleOne
  3. Configuring Users and Permissions
    1. Require users to log in with a user name and password
    2. Only allow users in a particular OU to log in
    3. Grant additional permissions to a specific user
    4. Grant permissions based on LDAP group membership
    5. Grant access to the Address Book based on LDAP group membership
    6. Deny access to the Address Book for a specific user
    7. Changing the user DN search behavior
  4. Customizing the Address Book
    1. Changing the attributes used for searching
    2. Changing the columns shown for lists of directory entries
    3. Applying language-specific sorting rules for search results
    4. Applying custom LDAP filters to directory browsing and searching
      1. Directory browsing
      2. Search results
    5. Changing the layout and attributes shown for directory entries
    6. Displaying thumbnail photos or logos when browsing/searching the directory
    7. Setting up phone numbers to be dialed when clicked on
    8. Changing the links shown in the page footer
    9. Changing the look and formatting of the address book
    10. Changing the country code interpretation
    11. Extending and modifying the schema
    12. Using auxiliary object classes
  5. Linking External Records to the Address Book
    1. Linking to additional records within a single LDAP server
    2. Creating a multi-directory Address Book
      1. Connecting to additional servers
      2. Defining users and permissions for each server
      3. Configuring the address book structure
    3. Troubleshooting
  6. Configuration Reference

Getting Started Using the Address Book

LDAP Address Book is a web application for browsing and searching for contact details within an LDAP directory service, allowing it to be used as an address book. It has been tested on the following LDAP directories:

Searching your LDAP address book is pretty easy. Just type in the name, job title or company of who you're trying to find into search box and click "Search" (or press Return). Alternatively if the directory has been classified into "organizational units" (OUs) you can click on the folders underneath the search box to browse records by department, building, etc.

How to Search or Browse the Address Book

You can add the LDAP Address Book as a search engine in Firefox, Google Chrome/Chromium and other OpenSearch compliant web browsers, allowing you to search more easily.

Mozilla Firefox Search Integration

To add the Address Book as a search engine in Firefox:

  1. Open web browser and navigate to the address book.
  2. Click the icon to the left of the search engine name in the search box.
  3. Select Add "Address Book" (or the name of your address book, if it has been changed from the default) from the menu.

Address book OpenSearch integration in Firefox

Google Chrome/Chromium Search Integration

To add the Address Book as a search engine in Google Chrome or Chromium:

  1. Open web browser and navigate to the address book.
  2. Chromium/Google Chrome will automatically add the LDAP Address Book to the available search engines.

To search the Address Book, first enter the first few characters of the site URL, then press Tab when prompted.

Selecting Address Book OpenSearch in Chromium Browser

Now enter the name you wish to search for.

Using Address Book OpenSearch in Chromium Browser


Installation and Basic Setup

The remainder of this document is aimed towards system administrators setting up and configuring LDAP address book on your network.

Upgrading from Previous Versions

The general method of upgrading to a new version of the Address Book is to replace the application's program files with those from the new release.

In many cases your previous configuration (stored in file config.php) can be reused with only minor changes (if any). Details of what needs to be done for each version can be found on the project Wiki:

https://sourceforge.net/p/ldap-addr-book/wiki/Home/

This information is available for version 0.10 and later.

Installation on Linux

LDAP Address Book requires a number of packages to be installed in order to run - primary a web server, PHP and a number of PHP add-on modules. The following table shows the commands to install these prerequisites for a number of common web servers and Linux distributions.

Web ServerOperating SystemInstall Commands
Apache HTTP ServerUbuntu 12.04sudo apt-get update
sudo apt-get install apache2 libapache2-mod-php5 php5 php5-gd php5-intl php5-ldap
Ubuntu 16.04
Ubuntu 18.04
sudo apt update
sudo apt install apache2 libapache2-mod-php php php-gd php-intl php-ldap php-mbstring
NginxCentOS 6sudo yum install epel-release
sudo yum install nginx php-fpm php-gd php-intl php-ldap php-mbstring
 
# PHP session directory is not created by default
sudo mkdir /var/lib/php/session/

Next, decide where you want to store the address book web site's files and unpack the address book tar.gz file to the web site directory. For the purposes of this guide, this location is assumed to be /srv/www/addressbook.example.org and the URL of the address book http://addressbook.example.org/, in which case you might type:

mkdir -p /srv/www/addressbook.example.org
cd /srv/www/addressbook.example.org
tar xvzf ~/ldap-addr-book-0.02.tar.gz

You'll probably need to create a DNS record for the address book web site, for example:

addressbook.example.org.	IN	CNAME	myserver

The procedure for setting up the web site varies according to the Linux distribution and web server software being used. Once your web server has been configured, opening the Address Book's URL should display the following message:

The Address Book's configuration file (config.php) is missing.

Apache HTTP Server on Ubuntu 12.04 and similar Debian derivatives

Create the file /etc/apache2/sites-available/addressbook.example.org and add the following contents:

<VirtualHost *:80>
        DocumentRoot /srv/www/addressbook.example.org
        ServerAdmin webmaster@example.org
        ServerName addressbook.example.org

        ServerSignature email
        DirectoryIndex index.html index.php

        LogFormat "combined"
        TransferLog /var/log/apache2/addressbook.example.org-access_log
        ErrorLog /var/log/apache2/addressbook.example.org-error_log
</VirtualHost>

Enable the site by running the command:

a2ensite addressbook.example.org

Perform a graceful restart of Apache in order to re-read the configuration and make the new web site live:

apache2ctl graceful

Installation on Windows: Apache HTTP Server or Microsoft IIS

In outline, the procedure to set up the LDAP Address Book to run under Windows is as follows:

Once your web server has been configured, opening the Address Book's URL should display the following message:

The Address Book's configuration file (config.php) is missing.

Set up access to the directory service

First, copy (or rename) the sample configuration file supplied with LDAP Address Book, config.php.sample to config.php.

Open the file in your preferred text editor and change the $ldap_server setting to tell the application where your Address Book data is stored. You'll need to specify:

Below is an example $ldap_server setting:

$ldap_server = new ldap_server(
        "openldap",                             // LDAP server type
        "OU=People,DC=example,DC=org",          // DN of address book
        "ldap.example.org",                     // host name/IP address/URL
        389                                     // port number
        );

See the Configuration Reference section below for further information on these and other settings.

Note: Windows users may experience problems opening the config.php file using the default "Notepad" text editor. Try downloading and using Notepad++ instead, which should be able to open and edit the file correctly.

Some LDAP directory servers will allow limited read access without having to enter any user name or password (known as allowing "anonymous bind" access). If your directory is set up to allow this then you should be able to open the LDAP Address Book in your web browser and view its contents.

Note: Anonymous access may have very limited read permissions. Some attributes (e.g. telephone numbers) may appear blank unless you log in by name.

If anonymous access is not allowed then you'll get the message "Please log in to use the address book" when you open the LDAP Address Book in your web browser.

The LDAP Address Book will need at least one user login account on the directory service in order to access its contents. This can be either:

If you just want to get the LDAP Address Book up and running quickly, set up a new user account that provides read-only access to your directory, open the config.php in your preferred text editor and locate the following section:

$ldap_server->add_user("__ANONYMOUS__",
        array(
                // LDAP login (or bind DN) to connect to the directory
                //
                // If the LDAP server is set up to allow "anonymous bind"
                // then the the user name and password can be left blank,
                // otherwise replace with a "generic" user that has read
                // permission.

                "ldap_dn"=>"",
                "ldap_password"=>"",

                // Permissions granted to anonymous users:

                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true
        ));

Fill in the values of "ldap_dn" and "ldap_password" with the user account's DN and password. Once the details are correct you should be able to open the LDAP Address Book in your web browser and view its contents.

The section What is an LDAP distinguished name (DN)? (below) gives more information about LDAP DNs and how to fill in the ldap_dn setting correctly. It is also possible to configure individual logging in with individual user names and passwords - see Configuring Users and Permissions for more information.

What is an LDAP distinguished name (DN)?

You'll need to use LDAP distinguished names (DNs) in a few places when configuring the LDAP Address Book:

This section gives a brief overview of what a DN is and how to find which DNs to use when configuring the Address Book.

LDAP records are organized into a "directory information tree" (DIT) of categories and subcategories - similar to how files and folders (directories) are stored on a computer's hard disc.

Each record in the directory is identified by it's name and location within the tree - known as its "Distinguished Name" or DN. A distinguished name consists of a comma-separated representing the "navigation path" through the tree to the object. Here's an example:

CN=John Doe,OU=Friends,O=BigCorp

Each item in the list is represented by an attribute and its value. In the above example:

The attribute used to identify each item varies according to its type, for example:

Here's how to work out the DNs from the graphical admin tools for Microsoft Active Directory and Novell eDirectory.

DNs as shown in Active Directory Users and Computers

The Active Directory Users and Computers admin tool shows the LDAP directory tree in the left-hand panel of its window. Icons are used to represent the type of each object.

Active Directory Users and Computers showing example AD domain layout

The top-level object shown in Active Directory Users and Computers is the domain. The name of the domain is shown as a series of elements separated by dots (e.g. turnersoft.co.uk), however this is not the domain's LDAP distinguished name. Each element of the domain name is represented as a separate domain component (DC) in LDAP notation:

DC=turnersoft,DC=co,DC=uk

The second-level elements within the domain include organizational units (shown with a folder icon overlaid with a book/grey blob) and containers (shown as a folder icon without a book).

The DN of the "Home" organizational unit in the above screenshot is:

OU=Home,DC=turnersoft,DC=co,DC=uk

If you wanted the LDAP Address Book to show only the contents of the "Home" organizational unit, you might configure the $ldap_server setting (in config.php) as follows:

$ldap_server = new ldap_server(
        "ad",                                   // LDAP server type
        "OU=Home,DC=turnersoft,DC=co,DC=uk",    // DN of address book
        "dc1.turnersoft.co.uk",                 // host name/IP address/URL
        389                                     // port number
        );

Containers are similar to organizational units, but are named using their CN (common name) attribute. The DN of the "Users" container is:

CN=Users,DC=turnersoft,DC=co,DC=uk

Users are named using their CN (common name) attribute. For example, the DN of the Administrator user for this domain is

CN=Administrator,CN=Users,DC=turnersoft,DC=co,DC=uk

LDAP Address Book also allows you to specify an Active Directory user by their User Principle Name (UPN), i.e. their user login name followed by @ followed by the domain's DNS name (or other allowed UPN suffix, if any have been configured). This allows a user to be specified independently of its position in the directory information tree.

The Administrator user for this domain has the UPN:

Administrator@turnersoft.co.uk

DNs as shown in Novell iManager or ConsoleOne

The iManager and ConsoleOne admin tools also show the LDAP directory structure as a tree of objects. As with Active Directory Users and Computers, icons are used to represent the type of each object.

Novell iManager showing example eDirectory tree layout

The top-level object is the tree, which is not included in the LDAP DN. The DN of the "turnersoft" organization in the above screenshot is:

o=turnersoft

The DN of the "Home" organizational unit in the above screenshot is:

ou=home,o=turnersoft

Users are named using their CN (common name) attribute. For example, the DN of the "admin" user for this tree is:

cn=admin,o=turnersoft


Configuring Users and Permissions

The LDAP address book supports logging in with named user accounts. Typically, this is used by administrators who are permitted to edit the address book contents, or if you need to limit browsing/searching access to known users.

Once per-user access has been set up, users can log in with their own user names and passwords by clicking the "log in" link in the top-right corner of each page. (This link is not displayed if only anonymous access has been configured.)

Log In link - Visible when per-user login enabled

User login names, passwords and permissions are taken from the LDAP directory itself rather than the address book application.

LDAP does not provide any (standard) way of retrieving a user's permissions, so the $ldap_server->add_user() configuration command should be used to tell the Address Book which facilities should be made available to each user. within the back-end directory.

Three types of user mapping can be defined:

The following settings can be applied to each user map entry in order to enable or disable various features of the address book. To use each feature, the necessary permissions will also need to be granted within the back-end directory.

SettingDescription
ldap_dnSpecifies the LDAP DN (or alternatively the UPN when used with Active Directory) used to log in to the directory. The token __USERNAME__ will be replaced by the actual user name as typed into the login dialogue. If not set then the Address Book will search for the user's DN automatically.
ldap_passwordSpecifies the password to be used when connecting to the directory. This is only used for the __ANONYMOUS__ user.
allow_browseAllows the user to browse through organizational units (folders) within the address book.
allow_createAllows the user to create new records within the address book. They will also need to be granted allow_edit in order to populate and save the new record's attributes.
allow_deleteAllows the user to delete records within the address book.
allow_editAllows the user to edit records within the address book.
allow_edit_selfAllows the user to edit only their own record within the address book.
allow_moveAllows the user to move records between different organizational units (folders) within the address book.
allow_searchAllows the user to search the address book directory tree.
allow_viewAllows the user to click on a record to see full details
allow_extendAllows the user to extend records by adding auxiliary classes. They will also need to be granted allow_edit in order to populate the newly-added attributes and save their changes.
allow_exportAllows the user to save/export (individual) records as vCard electronic business cards.
allow_export_bulkAllows the user to export entire OUs of records (or the complete address book) in vCard format, for example to import into another address book or contact database that doesn't support LDAP directly.
allow_folder_infoAllows the user to view and (if allow_edit is also granted) edit folders, OUs and other container objects.
allow_loginAllows the user to log in to the directory. This permission is granted automatically if not specified explicitly.
allow_ldap_pathAllows the user to see the location of the current entry in the "navigation path" at the top of the screen. This permission is granted automatically if not specified explicitly.
allow_system_adminAllows the user to see LDAP server information (root DSE record) and access records other than those under the root of the address book ($ldap_server->base_dn).
front_page_search_filterSpecifies an LDAP search filter to use for the Address Book's front page. When this option is set, the Address Book will display the results of this search instead of listing the records located directly under the root of the address book ($ldap_server->base_dn). Examples:
"front_page_search_filter"=>"objectClass=person" will display a flat list of all people/contacts on the front page.
"front_page_search_filter"=>"directReports=*" will display a list of all managers (people with at least one other person reporting to them) in Active Directory.

Require users to log in with a user name and password

The following example shows how to grant all logged in users permission to browse, search or view the Address Book (assuming the __ANONYMOUS__ user has been disabled or removed from the configuration):

$ldap_server->add_user("__DEFAULT__",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true
        ));

Only allow users in a particular OU to log in

The following example shows how to allow only those users in a particular OU to log in to browse, search or view the Address Book:

$ldap_server->add_user("__DEFAULT__",
        array(
		"ldap_dn"=>"cn=__USERNAME__,dc=home",
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true
        ));

Grant additional permissions to a specific user

The following example shows how to grant additional permissions to a specific user. The user name "admin" will be logged in using with Active Directory UPN Administrator@example.org (the default domain administrator).

$ldap_server->add_user("__DEFAULT__",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true
        ));
$ldap_server->add_user("admin",
        array(
                "ldap_dn"=>"Administrator@example.org",
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_create"=>true,
                "allow_edit"=>true,
                "allow_delete"=>true,
                "allow_export"=>true,
                "allow_export_bulk"=>true
        ));

Permissions granted to a user by name will be used instead of the __DEFAULT__ permissions. In the above example, admin will not receive the allow_folder_info permission.

Grant permissions based on LDAP group membership

Permissions can be granted to an LDAP group using the $ldap_server->add_group() configuration command. Members of the group will receive the group's permissions. In the following example, logged in users will receive permissions to browse, search and view the Address Book. Users who are members of the Address Book Admins are also granted permission to create, edit and delete records.

$ldap_server->add_user("__DEFAULT__",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true
        ));

$ldap_server->add_group("cn=Address Book Admins,ou=HR,o=BigCorp",
        array(
                "allow_create"=>true,
                "allow_edit"=>true,
                "allow_delete"=>true
        ));

Alternatively, permissions can be granted according to LDAP group membership by specifying the group name as the permission's value. The following example shows how to use this method:

$ldap_server->add_user("__DEFAULT__",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_create"=>"cn=Address Book Admins,ou=HR,o=BigCorp",
                "allow_edit"=>"cn=Address Book Admins,ou=HR,o=BigCorp",
                "allow_delete"=>"cn=Address Book Admins,ou=HR,o=BigCorp"
        ));

Note:

The $group_member_attributes setting is used to define which attributes of a group are checked in order to determine whether the user is a member:

$group_member_attributes = array("member","roleOccupant","memberUid");

The various group membership attributes allows different types of object to be used to represent roles and permissions:

Group Member Attribute Used to Check Membership Of
member groupOfNames, group (Active Directory)
roleOccupantorganizationalRole
memberUid posixGroup

Grant access to the Address Book based on LDAP group membership

The allow_login permission can be used to decide whether users will be allowed to log in to the address book. It is automatically granted if not explicitly defined. The following example shows how to grant login permission based on group membership:

$ldap_server->add_user("__DEFAULT__",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_login"=>"cn=Address Book Users,ou=HR,o=BigCorp"
        ));

Deny access to the Address Book for a specific user

A specific user can be prevented from accessing the address book (whilst continuing to allow others to log in) by setting their "allow_login" permission to "false". For example, the following might be used to prevent the directory's top-level administrative account from being (mis)used to browse the address book:

$ldap_server->add_user("Administrator",array("allow_login"=>false));

Changing the user DN search behavior

The LDAP Address Book searches the directory in order to determine a user's DN during the login process.

By default, the Address Book will search for login user accounts in the same area of the directory as the address book data (i.e. under the location indicated by $ldap_server->base_dn). If you wish to store the login accounts in a different location outside of this area (e.g. for security reasons) then the setting $ldap_server->dn_search_base can be used:

$ldap_server->dn_search_base = "CN=Users,DC=example,DC=org";

Searching is carried out using an anonymous connection by default. The $ldap_server->dn_search_user and $ldap_server->dn_search_password settings can be used to specify a different account to use when searching for a user's DN:

$ldap_server->dn_search_user = "CN=ldap-browse,OU=Service Accounts,DC=example,DC=org";
$ldap_server->dn_search_password = "foobar";

Customizing the Address Book

Changing the attributes used for searching

The fields/attributes that are used when searching can be customized by editing the contents of $search_ldap_attrib in the configuration file. The default setting is:

$search_ldap_attrib = array(
        "cn","mail","sn","displayName","company","title");

...which searches the following set of attributes:

AttributeDescription (typical usage)
cnName of the directory entry itself (usually a person's full name or "common name")
mailE-mail address
snSurname
displayNamePreferred display version of user's name. Some users may prefer informal versions of their name (e.g. "Andy" instead of "Andrew"), which would be represented here.
companyCompany name
titleJob title

See your directory service's schema documentation for other attributes which are available to be searched.

Changing the columns shown for lists of directory entries

You can change the columns/attributes used to display directory entries in a list using the configuration function set_display_columns():

$ldap_server->set_display_columns("*",
        array(
                array("caption"=>"Name",                "attrib"=>"sortableName",       "link_type"=>"object"),
                array("caption"=>"E-Mail",              "attrib"=>"mail",               "link_type"=>"mailto"),
                array("caption"=>"Web Site",            "attrib"=>"wWWHomePage",        "link_type"=>"url"),
                array("caption"=>"Office Phone",        "attrib"=>"telephoneNumber",    "link_type"=>"phone_number"),
                array("caption"=>"Mobile Phone",        "attrib"=>"mobile",             "link_type"=>"phone_number")
                )
        );

The special attribute sortableName can be used to display a "sort-friendly" version of a personal name (Surname, Firstname) where this information is available. (This is constructed from the sn and givenName attributes if populated, otherwise falling back to displayName and cn.)

You can display different sets of columns for specific areas of your directory - for example you may want to display different columns for "Staff" and "External Contacts" OUs:

$ldap_server->set_display_columns("ou=Staff",
        array(
                array("caption"=>"Name",                "attrib"=>"sortableName",       "link_type"=>"object"),
                array("caption"=>"E-Mail",              "attrib"=>"mail",               "link_type"=>"mailto"),
                array("caption"=>"Home Phone",          "attrib"=>"homePhone",          "link_type"=>"phone_number"),
                array("caption"=>"Office Phone",        "attrib"=>"telephoneNumber",    "link_type"=>"phone_number"),
                array("caption"=>"Mobile Phone",        "attrib"=>"mobile",             "link_type"=>"phone_number"),
		array("caption"=>"Employee ID",         "attrib"=>"employeeNumber",     "link_type"=>"none")
                )
        );

$ldap_server->set_display_columns("ou=External Contacts",
        array(
                array("caption"=>"Name",                "attrib"=>"sortableName",       "link_type"=>"object"),
                array("caption"=>"E-Mail",              "attrib"=>"mail",               "link_type"=>"mailto"),
                array("caption"=>"Office Phone",        "attrib"=>"telephoneNumber",    "link_type"=>"phone_number"),
                array("caption"=>"Mobile Phone",        "attrib"=>"mobile",             "link_type"=>"phone_number"),
                array("caption"=>"Office Fax",  "attrib"=>"facsimileTelephoneNumber",   "link_type"=>"none"),
                array("caption"=>"Organization",        "attrib"=>"company",            "link_type"=>"none"),
                array("caption"=>"Web Site",            "attrib"=>"wWWHomePage",        "link_type"=>"url")
                )
        );

Use * as the location in order to specify the default set of display columns for other areas of the directory. This set of columns will be used when listing search results.

Applying language-specific sorting rules for search results

Certain languages and countries have their own specific sorting rules (e.g. the sequence in which alphabetic characters follow each other). Where necessary, these rules can be selected through the $lc_collate setting in config.php:

$lc_collate = "<language>[_<territory>][.<codeset>][@<modifier>]";

In practice neither the code set or modifier are widely used, and in most cases only the language and territory need to be defined, for example:

$lc_collate = "en_US";

(a code set of UTF-8 will be assumed automatically.)

Applying custom LDAP filters to directory browsing and searching

If is possible to customize the LDAP queries which are used to fetch data from the directory, for example to display only records which have specific object classes or meet some other criteria.

Sites with Microsoft Active Directory/Exchange may wish to set up custom filters that test the msExchHideFromAddressLists and/or showInAddressBook attributes in order to exclude those entries which are hidden from Exchange's Global Address Book (GAL).

Directory browsing

When the user browses through the directory tree directory, the address book retrieves all records at the user's location (LDAP base search) that match the criteria specified by $browse_ldap_filter in config.php. The default LDAP filter is as follows, which allows all objects to be displayed:

$browse_ldap_filter = "objectClass=*";

Search results

Searches results are retrieved by carrying out an LDAP subtree search from the root of the address book (as specified in $ldap_server->base_dn). The expression to be searched for is based on the value of $search_ldap_filter in config.php. The default LDAP filter is as follows, which limits search results to objects representing people:

$search_ldap_filter = "(&(objectClass=person)___search_criteria___)";

The token ___search_criteria___ will be replaced with an expression to search the attributes listed in $search_ldap_attrib for the string entered by the user. For example if the user searched for "smith", the token would be replaced by:

(|(cn=smith)(mail=smith)(sn=smith)(displayName=smith)(company=smith)(title=smith))

To allow all object types to appear in search results, including organizational units (which typically do not have a cn attribute set), make the following changes to config.php:

Changing the layout and attributes shown for directory entries

You may want to customize the way in which address book entries are displayed - which fields/attributes are used and how they are laid out. If you wish, you can specify a different layout for each type of record.

As shipped, a default layout is provided which displays the address book entries in three "sections":

Default address book layout, with personal, business/work and additional notes sections

This layout is created by the configuration shown below. The layout will be used when displaying inetOrgPerson, user or contact records. Specifying * instead of a list of object classes means that the layout should be applied for all types of record (unless overridden by another definition applying to a specific record type). The layout itself is described as a comma-separated list of arrays.


$ldap_server->add_display_layout("inetOrgPerson,user,contact",array(
        array("section_name"=>"Personal",
                "attributes"=>array(
                        array("givenName",                      "Given Name",           "contact24.png","allow_view"=>false),
                        array("sn",                             "Surname",              "contact24.png","allow_view"=>false),
                        array("cn",                             "Full Name",            "contact24.png","allow_view"=>false),
                        array("displayName",                    "Preferred Name",       "contact24.png"),
                        array("mail",                           "E-mail",               "mail.png","allow_edit"=>false),
                        array("homePhone",                      "Home Phone",           "landline-phone.png"),
                        array("mobile",                         "Mobile Phone",         "cell-phone.png"),
                        array("wWWHomePage",                    "Web Page",             "internet.png"),
                        array("streetAddress:l:st:postalCode",  "Postal Address",       "address.png"),
                        array("c",                              "Country",              "country.png")
                        )
                ),

        array("section_name"=>"Business/Work","width"=>"50%",
                "attributes"=>array(
                        array("company",                        "Company",              "company.png"),
                        array("url",                            "Web Page",             "internet.png"),
                        array("telephoneNumber",                "Office Phone",         "landline-phone.png"),
                        array("facsimileTelephoneNumber",       "Office Fax",           "fax.png"),
                        array("title",                          "Job Title",            "org-role.png"),
                        array("department",                     "Department",           "org.png"),
                        array("physicalDeliveryOfficeName",     "Office",               "office.png"),
                        )
                ),

        array("section_name"=>"Additional Notes","new_row"=>true,"colspan"=>2,
                "attributes"=>array(
                        array("info")
                        )
                )
        ));

The givenName, sn and cn fields will not be visible except while the record is being edited. The mail field will be read only, and cannot be edited by end users.

Note: Some attributes must always be filled in with a value, for example many LDAP directories require record types representing a person to have the surname (sn) attribute filled in. If you want to be able to create new records through the Address Book then these attributes must be included in your directory entry layout so that users can fill them in.

You can define the following settings for each section:

SettingDescriptionDefault if not set
section_name Title to appear above the section. Title is not shown.
new_row Whether or not this section should start on a new row.
In the default setup the "Business/Work" section has "new_row"=>false set, so it is displayed to the right of "Personal" on the same row. "Additional Notes" has "new_row"=>false set, so appears on its own row below the previous sections.
Assumed to be false
width Width of the section, specified as a number followed by any of the following measurement units (which are those supported by the CSS standard):
  • % - percentage of the available width
  • px - pixels
  • em - current font size (traditionally the width of the letter "m" in the font)
  • ex - half current font size (traditionally the height of the letter "x" in the font; or the distance between the font baseline and median)
  • cm - centimeters
  • mm - millimeters
  • in - inches
  • pt - points (1/72 of an inch)
  • pc - picas (1/6 of an inch, or 12 points)
In the default setup the width of "Business/Work" is set to "50%". Any sections on the same row that don't have a specified width will automatically use up the remaining space.
User's browser divides up the available width based on amount of data to be shown in each section
colspan Number of HTML table columns that this section should span.
In the default setup the "Additional Notes" section has "colspan"=>2 set, so spans the width of both the "Personal" and "Business/Work" columns.
Assumed to be 1
attributes List of attributes to appear in the section. (always required)

Each attribute is described by either three or four items:

  1. The name of the LDAP attribute (or list of attributes) to be displayed
  2. The caption text to appear next to the attribute (or leave empty - "" - for no caption)
  3. Icon image to appear next to the attribute (or leave empty for none)
  4. Whether the attribute should be visible only while the record is being edited

A display field can be constructed from several LDAP attributes. To construct a field from multiple attributes, list the attributes in turn, separating them with one of the following symbols:

SymbolMeaning
:Separate attributes with a line break
+Separate attributes with a space

This facility is often used to display the lines of an address. (If the address attributes in your LDAP directory are used to store business addresses rather than personal addresses you may want to relocate the "Address" field from the "Personal" to the "Business/Work" section of the display.)

The following changes will be applied automatically:

More information about displaying images can be found in the following section.

Displaying thumbnail photos or logos when browsing/searching the directory

By default, directory entries are displayed next to an icon representing their object class. Alternatively, the address book can be set to display an image - typically a photo or logo - representing the object instead. These images are retrieved from the following LDAP attributes (listed in order of priority):

AttributeDescription
jpegPhotoUsed to store one or more images of a person using the JPEG File Interchange Format. (Standard ref: IETF RFC 2798) In practice the Address Book will only display the first stored image.
thumbnailPhotoStores a single thumbnail image, maximum size 100K. (Non-standard/Microsoft specific)
thumbnailLogoStores a single thumbnail image, maximum size 32K. (Non-standard/Microsoft specific)

The LDAP Address Book can also display PNG, GIF, WBMP, and GD2 images stored in these attributes, although JPEG is recommended in all cases. (WBMP is not the same thing as Microsoft Windows BMP, which is not supported.) Your PHP installation must have GD Graphics Library support enabled in order to display image attributes.

To display thumbnail photos/logos instead of "generic" icons, set one or both of the following options in config.php:

SettingDescription
$enable_search_browse_thumbnail = true; Display thumbnail photos when browsing and in search results
$enable_ldap_path_thumbnail = true; Display thumbnail photo in detail view navigation path

Beware that setting $enable_search_browse_thumbnail = true can result in slow page loading if there are a large number of images to be displayed.

A larger version of these images can be shown on the entry's detailed view by adding the jpegPhoto and/or thumbnailPhoto to the display layout (as described in the previous section). The following settings control the image size:

SettingDefault valueDescription
$thumbnail_image_size 24x24 Size of thumbnail images displayed in search results and/or detail view navigation path, measured in pixels. For optimal layout the size should be the same as the icons used to represent object schema classes (24x24 as shipped).
$photo_image_size 96x96 Size of large images displayed in detail view, measured in pixels. Set this value to an empty string (or leave undefined) to disable scaling of these images.

Android devices (at least as of version 4.4) will display the logo in preference to the photograph wherever a contact record includes both. To omit the logo from any records that have a photo (so that the photo will be used) when saving as vCard, set the following option in config.php:

$exclude_logo_if_photo_present = true;

Setting up phone numbers to be dialed when clicked on

Phone numbers appearing in the directory can be set to be displayed as HTML links rather than plain text, usually so that the number will be dialed when clicked on. The way that phone numbers are converted into URLs can be configured via the $phone_number_link_template setting in order to support different types of "click-to-dial" software.

The following setting allows many mobile phone browsers and other platforms that have built-in phone support to dial a number when clicked on:

$phone_number_link_template = "tel:___phone_number___";

The following setting will enable phone numbers to be dialed using Microsoft Skype or other software that handles the (non-standard) callto: URI scheme:

$phone_number_link_template = "callto://___phone_number___";

The following settings show how to place a call by passing the phone number to a separate web application such as Cisco WebDialer:

$phone_number_link_template = "https://cucm01/webdialer/Webdialer?destination=___phone_number___";
$phone_number_link_target = "_blank";

If defined, the $phone_number_link_target setting can be used to force the dialing application to open in a separate window/tab.

Changing the links shown in the page footer

The links shown in the page footer can be changed using the $site_footer_links option in config.php. The default set of links are defined as follows:

$site_footer_links = array(
        array("url"=>"doc/","text"=>"User Guide"),
        array("url"=>"https://sourceforge.net/projects/ldap-addr-book/",
                "text"=>"Get Source Code")
        );

Each link is represented by an array containing its URL and the name/label text to be displayed.

Note: The application's software license requires that you provide users with a means of obtaining a copy of the source code. As such you are recommended not to remove the "Get Source Code" link from the footer, although you may change it to a more appropriate URL where necessary (e.g. to a copy containing your own local changes, or if users have only limited connectivity to the external Internet that would prevent them from accessing the default location.)

Please see the license agreement for full information.

Changing the look and formatting of the address book

The appearance (such as font, text size, colors, etc) of the address book is defined in the file styles.css.

Take a look at the stylesheet file (styles.css)

You can change any of these settings (or add your own) by creating your own stylesheet file, called styles_local.css and adding your changes to it. (Although you could modify styles.css directly it will be easier to upgrade to future versions of the address book if you keep your changes separate by using styles_local.css instead.)

The stylesheet file is made up of selectors which specify which part of the user interface is to be changed, followed by style directives surrounded by {...} to define how it should appear. For example, if you wanted to display the address book in a different font you might add the following to your own styles_local.css file and change the font-family setting to your own choice of font:

body,table,textarea {
        font-family:serif;
}

Where you don't redefine a setting in styles_local.css (such as font-size:10pt in this example) the value from styles.css will continue to be used.

The following table summarizes the CSS selectors used within styles.css and which part of the address book's appearance they affect:

CSS SelectorTypically used to change the font, size, color, etc, of...
body,table,textarea The address book as a whole.
.ldap_navigation_path li:first-child The address book title, which is shown as the left-most item in the "Navigation Path" shown at the top of each page.
.ldap_navigation_path li+li:before Organizational units, folders, etc, shown in the "Navigation Path" at the top of each page. The left-most element of the navigation path (typically used to show the address book title) is styled separately, described above.
.page_footer Page footer.
.ldap_entry_viewer_section .column_header,
.search_results_viewer .column_header
Column headers/titles used in search results and directory entries.(*)
.ldap_entry_viewer_section td,
.search_results_viewer td
Data displayed in search results and directory entries.(*) Note: The appearance of LDAP attributes can be customized individually, as described below.
.ldap_entry_viewer_section th Name/label text that appears to the left of each attribute shown in a directory entry.

(* These may be split into two separate style declarations if you want to customize the search results and directory entry detail pages separately.)

You can also change the way in which an individual LDAP attribute is displayed by applying style directives to .ldap_attribute_<attrib>, where <attrib> is the attribute to be customized.

For example, adding the following to styles_local.css will cause home telephone numbers (stored in the homePhone attribute) to be displayed in italic:

.ldap_attribute_homePhone
{
        font-style:italic;
}

As a further example, adding the following to styles_local.css will display SSH public keys (stored in the sshPublicKey attribute) to be displayed in a fixed-width font and word-wrapped more appropriately:

.ldap_attribute_sshPublicKey
{
        font-family:monospace;
        word-break:break-all;
}

Changing the country code interpretation

Country codes in LDAP directories normally follow the ISO 3166 standard. The $country_code_standard setting in config.php contains a comma-separated list of which parts of the standard should be used by the Address Book. By default, only the ISO 3166-1 alpha2 officially assigned codes will be used:

$country_code_standard="official";

If your records use country codes for countries which have since been renamed or are no longer in existence, you may want to enable additional parts of ISO 3166, for example:

$country_code_standard="official,transitional,former";

This will enable the correct country names to be displayed, and for the older country codes to be selected from drop-down lists. The following table summarizes the available country code standards:

Country Code SettingDescription
official ISO 3166-1 Officially Assigned Codes
user ISO 3166-1 User-Assigned Codes

Country codes that have been reserved for organizations that use ISO 3166 to add further codes to their in-house implementations. Several of the more widely used/known country codes are listed by name.

exceptional ISO 3166-1 Exceptional Reservations

Reserved at the request of national ISO member bodies. Usage other than for the specific purpose which justified the reservation is discouraged. (See comments against each exceptional reservation in file lib/country.php for individual explanations.)

transitional ISO 3166-1 Transitional Reservations

Former official ISO 3166-1 country codes, reserved against reassignment (typically for 50 years) whilst existing historical uses are gradually phased out. These are also listed in ISO 3166-3 as former country codes.

indeterminate ISO 3166-1 Indeterminate Reservations

International vehicle registration codes, reserved against reuse in ISO 3166-1 for an indeterminate period until existing historical uses have been sufficiently phased out.

former ISO 3166-3 Formerly Assigned Codes

Previously assigned ISO 3166-1 alpha2 codes for countries that are no longer in existence.

The following alternative (non-standard) coding schemes are also supported if needed for specialist and/or legacy applications:

Country Code SettingDescription
wipo WIPO ST.3 Country Codes

Broadly similar to ISO 3166-1 alpha2 official assignments, but also includes codes which represent intellectual property organizations that participate in WIPO.

Several countries which appear in ISO 3166-1 (2013 ed.) are omitted from WIPO ST.3 - most likely because they are not autonomous for patent treaty purposes or otherwise not recognized by WIPO:

AQ AS AX BL CC CX FM GF GP GU HM IO MF MH MQ
NC NF NU PF PM PN PR PS RE SJ TF TK UM WF YT

ISO has agreed not to assign country codes which conflict with the WIPO participants, so the Address Book can use both ISO and WIPO standards together, e.g. by setting the country code standard to official,wipo.

(ISO have also agreed not to us "EF", which represented an older European patent treaty area, now superseded by "EP".)

fips FIPS 10-4 Country Codes

Country codes used by the US Government and agencies prior to September 2008, when the standard was withdrawn and ISO 3166 adopted in its place. It's coding is substantially different from ISO 3166, and the two standards cannot be used meaningfully together.

Extending and modifying the schema

The schema is a set of information which the Address Book uses to display and edit the different types of records. The schema information is stored inside the Address Book's schema subdirectory. The set of files that is loaded and used depends on the server type and/or on additional entries in the configuration file. The default set schema files used for each server type are:

Server typeSchema configuration files used
admicrosoft
edirnovell
openldapopenldap/system, core, cosine, nis, inetorgperson
custom(none)

You can load an additional schema file using $ldap_server->add_schema() from the configuration file. For example, the following commands will connect to an OpenLDAP server and allow objects and attributes from the Mozilla Address Book schema to be used (and displayed correctly) in addition to the default schemas:

$ldap_server = new ldap_server("openldap","dc=example,dc=org","ldap.example.org");
$ldap_server->add_schema("mozilla");

The following schema files are supplied with the Address Book. (Future versions may include additional files.)

Schema FileDescription
core Basic objects and attributes which make up the directory structure (such as definitions of person or surname). Adapted from on X.500 directory standards, described in IETF's RFC 2252 and RFC 2256.
cosine Additional objects/attributes which were identified and adopted as a result of the COSINE (Co-operation and Open Systems Interconnetion in Europe) initiative's PARADISE directory pilot project in the early 1990s. Described in IETF RFC 1124 (and its successors).
dhcp Allows the Address Book to be used to manage the Internet Software Consortium DHCP Server (dhcpd). This also allows a pair of DHCP servers to be set up as a failover cluster, sharing configuration and IP address lease data through an LDAP directory.
inetorgperson Enhanced object class for recording details of a person in an "organizational context" (e.g. a member of staff) on an Internet/Intranet directory. Described in IETF RFC 2798.
microsoft Objects and attributes used in Microsoft Active Directory ("AD"). These include redefinitions of Core, COSINE and inetOrgPerson (often with subtle differences) together with numerous Microsoft-specific classes.
mozilla Extends inetOrgPerson for storing additional attributes used by the address book feature of Mozilla Thunderbird and related products.
nis Allows the Address Book to manage a Network Information Service (NIS) server that has been set up to store its configuration data in LDAP. This is typically used for centrally managing UNIX/Linux-type operating systems on a network.
novell Objects and attributes used in Novell eDirectory (formerly called Novell Directory Services, NDS). These include redefinitions of Core, COSINE, NIS and inetOrgPerson (often with subtle differences) together with numerous Novell-specific classes.
openldap Versions of the organization, OU and Internet/intranet organizational person objects with additional attributes, as used in the OpenLDAP Project's own directory schema.
oracle Objects and attributes used to store information about Oracle databases and services in a central directory. Oracle clients can look up this information via LDAP instead of a locally-stored tnsnames.ora file on each machine.
ppolicy Defines objects for storing an LDAP directory's password policy within the directory itself. Administrators of OpenLDAP servers can configure the ppolicy overlay module to read these records and apply the policy settings.
schac Objects and attributes used to represent personal records in educational institutions (Schema for Academia).

Defining your own objects and attributes

Unless configured otherwise, the Address Book will display unrecognized object and attribute classes as follows:

This default behavior can be modified and extended by defining the object or attribute class (or enabling a schema file that defines it).

The following example shows how to define a container object class (similar to the one defined in the microsoft schema). The class which should appear as a folder - similar to an OU - so that users can navigate into it and see further objects inside. Users with allow_create permission should be able to create container objects from within the Address Book's user interface:

$ldap_server->add_object_class("container",array(
	"icon"=>"folder.png",
	"is_folder"=>true,
	"display_name"=>"Container",
	"can_create"=>true)
	);

The following example defines sshPublicKey as a multi-valued text attribute (data type text_list) intended to hold a list of the user's SSH public keys.

$ldap_server->add_attribute_class("sshPublicKey",array(
	"data_type"=>"text_list",
	"display_name"=>"SSH Public Key")
	);

Existing object and attribute classes can be deleted as follows:

delete_object_class($name);

delete_attribute_class($name);

(The main use of this is to delete an existing class so that you can redefine it with different settings.)

Object class schema settings

The following settings can be used in object class definitions:

SettingDefaultDescription
icongeneric24.pngFilename of an icon image to appear next to objects of this class
is_folderfalseWhether the object class should be displayed as a folder
display_name(class name)Display name of the object class
can_createfalseWhether objects of this class can be created from within the address book
rdn_attribcnAttribute which should be used as the RDN
required_attribs(none)Comma-separated list of attributes which are not permitted to be empty
extensions(none)Comma-separated list of auxiliary classes which should be added to all new objects of this class

The attribute used in the object's name (the RDN attribute) must always have a value and does not need to be listed in required_attribs.

Attribute class schema settings

The following settings can be used in attribute class definitions:

SettingDefaultDescription
data_typetextData type of this attribute (as per below)
display_name(class name)Display name of the attribute class

Attribute data types

The following values can be used in an attribute class's data_type setting in order to indicate the type of data and how it should be displayed/edited:

Data TypeDescription
ad_group_typeActive Directory group type and scope (microsoft schema)
country_codeCountry code
dateDate.
date_timeDate and time
dn_listList of other objects in the directory, e.g. group members
genderGender
imageImage
phone_numberPhone number
postcodePost code
textSingle line of text
text_areaMulti-line text value (e.g. notes)
text_listList of text values
use_html_mailBoolean, presented as a choice whether HTML mail is prefered (mozilla schema)
yes_noBoolean, presented as a yes/no choice

Using auxiliary object classes

Auxiliary object classes can added to an LDAP record in order to extend its capabilities. For example, the simpleSecurityObject auxiliary class can be added to a contact object. This adds a new attribute for storing a password, allowing the record to be used as a user account for logging into the LDAP directory or an LDAP-enabled application.

Display layouts can be defined for auxiliary classes in the same way as "normal" object classes. Adding the following setting to the configuration file (config.php) will cause the LDAP Address Book to include the display layout of each auxiliary class whenever it displays an object that uses them:

$append_auxiliary_layouts = true;

You can use the extensions schema setting to add auxiliary class automatically whenever new objects are created. As an example, adding the following settings to the configuration file will enable users to create device objects and add IP addresses for each device.

$ldap_server->modify_object_class("device","can_create",true);
$ldap_server->modify_object_class("device","extensions","ipHost");

When viewing these device records, the top part of the display layout (with heading "Device Information") is defined for the device, whilst the bottom part of the display layout (with heading IP Address Information) comes from the ipHost auxiliary class.)

Granting allow_extend permission will allow users to add other auxiliary classes to records.

Current versions of the LDAP Address Book cannot remove auxiliary classes from a record.


Linking External Records to the Address Book

The configuration function link_ldap_dn() can be used to add Address Book records from another directory location (DN), outside of the main "tree" of records that make up the address book:

$ldap_server->link_ldap_dn(<link-location-dn>,
        <link-destination-server>,<link-destination-dn>,
	<link-method>,<link-name>,<link-object-class>);

This function can be used in place of LDAP server facilities such as aliases, referrals or proxies.

The parameters passed to link_ldap_dn() are used as follows:

<link-name> or <link-object-class> can be omitted if the name and object class don't need to be changed. To change the object class without affecting the name, use null in place of <link-name>.

Linking to additional records within a single LDAP server

Many Microsoft Active Directory installations have OU structures that were designed to meet systems administration requirements, but which are less suitable for browsing by end users. The screenshot below illustrates a common layout approach:

Original OU Structure

In this design, each department's directory records are stored in a separate set of OUs. Each department's OU is further divided in order to keep user accounts, groups and computer objects separate from each other.

The following configuration fragment shows how to create a more straightforward Address Book layout for users to browse, using records from the "Users" OUs inside each department:

$ldap_server = new ldap_server(
        "ad",
        "ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        "ldap.example.org",
        389
        );

$ldap_server->link_ldap_dn("ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        $ldap_server,"ou=Users,ou=Management,ou=Corporate HQ,dc=example,dc=org",
        "folder","Management Staff");

$ldap_server->link_ldap_dn("ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        $ldap_server,"ou=Users,ou=Marketing,ou=Corporate HQ,dc=example,dc=org",
        "folder","Marketing Staff");

$ldap_server->link_ldap_dn("ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        $ldap_server,"ou=Users,ou=Human Resources,ou=Corporate HQ,dc=example,dc=org",
        "folder","Human Resources Staff");

$ldap_server->link_ldap_dn("ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        $ldap_server,"ou=Users,ou=Finance,ou=Corporate HQ,dc=example,dc=org",
        "folder","Finance Staff");

An empty OU called "Address Book" should be created under "Corporate HQ".

End result:

Linked OU structure

The "contents" link method can be used to merge together the "users" OUs from more than one department. The following configuration fragment shows how to create a combined folder for "Management and Finance Staff":

$ldap_server->link_ldap_dn("ou=Management and Finance Staff,ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        $ldap_server,"ou=Users,ou=Management,ou=Corporate HQ,dc=example,dc=org",
        "contents");

$ldap_server->link_ldap_dn("ou=Management and Finance Staff,ou=Address Book,ou=Corporate HQ,dc=example,dc=org",
        $ldap_server,"ou=Users,ou=Finance,ou=Corporate HQ,dc=example,dc=org",
        "contents");

An empty OU called "Management and Finance Staff" should be created under "Address Book".

End result:

Merged OU contents

Creating a multi-directory address book

The link_ldap_dn() function can be used to include address book records from other LDAP servers, allowing you to create multi-directory address book.

This example shows how to create an address book that spans several LDAP directories, such as might exist in a large multinational organization.

Connecting to additional servers

First, define connections to the three directories which contain the Address Book records:

$ldap_server = new ldap_server(
        "openldap",                     // LDAP server type
        "ou=Address Book,dc=nodomain",  // base DN
        "ldap.example.org",             // host name/IP address/URL
        389                             // port number
        );

$ldap_server_corporate = new ldap_server(
        "edir",                         // LDAP server type
        "o=example",                    // base DN
        "edir.example.org",             // host name/IP address/URL
        389                             // port number
        );

$ldap_server_eu = new ldap_server(
        "ad",                            // LDAP server type
        "dc=ad,dc=eu,dc=example,dc=org", // base DN
        "ad.eu.example.org",             // host name/IP address/URL
        389                              // port number
        );

The LDAP server which hosts the top-level of the Address Book should be defined first, and should be stored in the variable $ldap_server.

Any customized record display layouts, schema definitions and other configuration changes will need to be applied for each individual server.

Defining users and permissions for each server

Each LDAP server has a user account called ldap-addr-book-browse (in an appropriate OU) which has been granted read-only access to the directory. These user accounts should be used to provide read-only access to the Address Book without having to log on:

$ldap_server->add_user("__ANONYMOUS__",
        array(
                "ldap_dn"=>"cn=ldap-addr-book-browse,ou=Users,dc=nodomain",
                "ldap_password"=>"XXXX",

                // Permissions granted to anonymous users:

                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true

        ));

$ldap_server_corporate->add_user("__ANONYMOUS__",
        array(
                "ldap_dn"=>"cn=ldap-addr-book-browse,o=example",
                "ldap_password"=>"YYYY",

                // Permissions granted to anonymous users:

                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true
        ));

$ldap_server_eu->add_user("__ANONYMOUS__",
        array(
                "ldap_dn"=>"cn=ldap-addr-book-browse,cn=Users,dc=ad,dc=eu,dc=example,dc=org",
                "ldap_password"=>"ZZZZ",

                // Permissions granted to anonymous users:

                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true
        ));

Users will also be able to log in to the Address Book by name, allowing them to access additional functionality (such as editing). During the login process, each server's ldap-addr-book-browse account will be used to look up the user's group membership so that group-based Address Book permissions can be assigned:

$ldap_server->dn_search_base = "dc=nodomain";
$ldap_server->dn_search_user = "cn=ldap-addr-book-browse,ou=Users,dc=nodomain";
$ldap_server->dn_search_password = "XXXX";

$ldap_server_corporate->dn_search_user = "cn=ldap-addr-book-browse,o=example";
$ldap_server_corporate->dn_search_password = "YYYY";

$ldap_server_eu->dn_search_user = "cn=ldap-addr-book-browse,cn=Users,dc=ad,dc=eu,dc=example,dc=org";
$ldap_server_eu->dn_search_password = "ZZZZ";

The dn_search_base setting specifies where to search for user accounts, and is needed if the user accounts are stored in a separate area of the directory to the the Address Book itself.

Logging into the Address Book as admin should grant additional permissions to $ldap_server and to $ldap_server_eu.

An admin user account should be created on $ldap_server and granted the necessary permissions, e.g. as per the following LDIF data:

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=extern
 al,cn=auth manage by * break
olcAccess: {1}to * by dn.exact=cn=admin,dc=nodomain manage
olcAccess: {2}to * by * read

Many Linux distributions will configure an admin or manager user automatically when OpenLDAP is installed. (Once the admin user has the necessary read/write access to object(s) in the cn=config container they will be able to manage directory permissions using the Address Book's web interface. Access to cn=config is not usually enabled by default.)

OpenLDAP Configuration

The following configuration statement will the corresponding admin access to the Address Book:

$ldap_server->add_user("admin",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true,
                "allow_create"=>true,
                "allow_edit"=>true,
                "allow_move"=>true,
                "allow_delete"=>true,
                "allow_export"=>true,
                "allow_export_bulk"=>true,
                "allow_system_admin"=>true
        ));

In this example, the Address Book's admin user will not have read/write access to the directory on $ldap_server_corporate, however they will be allowed to export its Address Book records (into vCard files). Access will use the same ldap-addr-book-browse user account and stored password as anonymous users.

$ldap_server_corporate->add_user("admin",
        array(
                "ldap_dn"=>"cn=ldap-addr-book-browse,o=example",
                "ldap_password"=>"YYYY",

                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true,
                "allow_export"=>true,
                "allow_export_bulk"=>true
        ));

The admin user will receive full read/write access to the directory on $ldap_server_eu. They will log on to it as ldap-addr-book-admin, which must have the same password as the admin user itself.

$ldap_server_eu->add_user("admin",
        array(
                "ldap_dn"=>"cn=ldap-addr-book-admin,cn=Users,dc=ad,dc=eu,dc=example,dc=org",

                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_folder_info"=>true,
                "allow_create"=>true,
                "allow_edit"=>true,
                "allow_move"=>true,
                "allow_delete"=>true
                "allow_export"=>true,
                "allow_export_bulk"=>true,
                "allow_system_admin"=>true
        ));

If you grant Address Book permissions based on group memberships, the groups must be located on the same server as the user.

Configuring the address book structure

In this example:

First, log in to the Address Book as admin and create the top-level records and other containers which will be stored directly in $ldap_server: "United States", "External Contacts" and "Global IT Helpdesk".

Top level Address Book objects

Finally, configure the links to $ldap_server_eu and $ldap_server_corporate.

$ldap_server->link_ldap_dn("ou=Address Book,dc=nodomain",
        $ldap_server_eu,"ou=Users,ou=London,dc=ad,dc=eu,dc=example,dc=org",
        "folder","GB","country");

$ldap_server->link_ldap_dn("ou=Address Book,dc=nodomain",
        $ldap_server_eu,"ou=Users,ou=Paris,dc=ad,dc=eu,dc=example,dc=org",
        "folder","FR","country");

$ldap_server->link_ldap_dn("ou=Address Book,dc=nodomain",
        $ldap_server_eu,"ou=Users,ou=Berlin,dc=ad,dc=eu,dc=example,dc=org",
        "folder","DE","country");

$ldap_server->link_ldap_dn("ou=Address Book,dc=nodomain",
        $ldap_server_eu,"ou=Users,ou=Rome,dc=ad,dc=eu,dc=example,dc=org",
        "folder","IT","country");

$ldap_server->link_ldap_dn("c=US,ou=Address Book,dc=nodomain",
        $ldap_server_corporate,"ou=Management,o=example",
        "folder","Management");

$ldap_server->link_ldap_dn("c=US,ou=Address Book,dc=nodomain",
        $ldap_server_corporate,"ou=Marketing,o=example",
        "folder","Marketing");

$ldap_server->link_ldap_dn("c=US,ou=Address Book,dc=nodomain",
        $ldap_server_corporate,"ou=Human Resources,o=example",
        "folder","Human Resources");

$ldap_server->link_ldap_dn("c=US,ou=Address Book,dc=nodomain",
        $ldap_server_corporate,"ou=Finance,o=example",
        "folder","Finance");

Organizational units from $ldap_server_eu are shown as countries at the top-level of the Address Book. (The country codes are automatically replaced with the corresponding country names.)

Links within top level of Address Book

Organizational units from $ldap_server_corporate are shown as folders within "US"/"United States":

Links within US subfolder

Troubleshooting

SymptomsSuggestion
Message "Linked DN: Can't contact LDAP server" is displayed instead of records from the linked server. Check that the Address Book has been configured to connect to the correct host and port number, the LDAP server software is installed and running and the connection is not being blocked by a host-based firewall. For reference, commonly used TCP port numbers for LDAP servers are:
  • 389 - Standard well-known port for unencrypted LDAP service
  • 636 - Standard well-known port for TLS (encrypted) LDAP service
  • 3268 - Well-known port for Active Directory "Global Catalog" unencrypted LDAP service
  • 3268 - Well-known port for Active Directory "Global Catalog" TLS (encrypted) LDAP service
Message "Linked DN: Invalid credentials" is displayed instead of records from the linked server. The current user needs to exist on the linked server and must have the same password. If this is not possible, the $target_ldap_server->add_user() configuration command can be used to specify that:
  • the current user should log onto the target server with a different user name (using the ldap_dn setting).
  • a different password should be used for accessing the linked server (using the ldap_password setting).
The ldap_dn and ldap_password options can be used to configure a shared/common user account for accessing the linked server. The shared account is often limited to read-only access.
Message "Linked DN: No read access to <server-name>" is displayed instead of records from the linked server. The current user needs to be granted allow_browse permission to the linked server. If you want the records to be visible when nobody is logged in to the Address Book (i.e. anonymous access) then you need to grant allow_browse to the linked server's __ANONYMOUS__ user.
Message "Linked DN: No such object" is displayed instead of records from the linked location. Either the linked location doesn't exist or the current user needs to be granted read access to it on the LDAP server. (This message appears when the current user does have allow_browse permission within the Address Book.)

Configuration Reference

SettingDescription
$site_nameSite name, which appears in the browser title bar. You may want to customize this, e.g. with your company name.

Example:
$site_name = "BigCorp Address Book";

$site_footer_linksList of links that appear in the footer of each page.
 
Example:
$site_footer_links = array(
        array("url"=>"doc/","text"=>"User Guide"),
        array("url"=>"https://sourceforge.net/projects/ldap-addr-book/",
                "text"=>"Get Source Code")
        );
Connection to LDAP Directory
$ldap_server Creates a connection to the LDAP server holding the address book data. The following information needs to be provided about the server:
  • LDAP server type. The following values are accepted:

    ad - Microsoft Active Directory (or Samba 4 Active Directory)
    edir - Novell eDirectory
    openldap - OpenLDAP (core/inetorgperson schema)

  • Location (base DN) within the LDAP directory where the Address Book records are stored.

  • Host name, port number or LDAP URL (or several, separated by spaces)

  • Port number (optional)

Examples:
$ldap_server = new ldap_server("openldap","ou=User Accounts,dc=example,dc=org","ldap.example.org"); - create an address book for records in the "User Accounts" OU.
$ldap_server = new ldap_server("openldap","dc=example,dc=org","ldap.example.org ldap-backup.example.org"); - fail over to a backup LDAP server if first is not available
$ldap_server = new ldap_server("openldap","dc=example,dc=org","ldapi://",0); - connect to local server via a UNIX domain socket

Active Directory-specific Options:

(1) As an alternative to giving the name of a specific server (domain controller) you can specify just the domain name. This will load balance the connections across the available domain controllers. (See Microsoft KB 842197 for further information on how to use DNS netmask ordering for more fine-grained control of the servers used for load balancing.)

(2) For multi-domain forests, specify the LDAP port number as 3268 in order to use the AD Global Catalog. (By comparison, using the default LDAP port (389) will return incomplete information other than for the local AD domain.)

$ldap_server = new ldap_server("ad","dc=example,dc=org","example.org"); - load balances across the DCs as listed in DNS
$ldap_server = new ldap_server("ad","dc=example,dc=org","dc1.example.org",3268); - use AD global catalog port

For further information, see: http://www.php.net/manual/en/function.ldap-connect.php

$ldap_server->dn_search_base Specifies the search base within the directory for looking up a potential user's DN during the login process.

Example:
$ldap_server->dn_search_base = "cn=Users,dc=example,dc=org"

$ldap_server->dn_search_user Temporary user name (bind DN) used by the address book software to search the LDAP directory for a user's DN when logging in. The corresponding password should be provided in $ldap_server->dn_search_password.

Examples:
$ldap_server->dn_search_user = "cn=LDAPUserLookup,cn=Users,dc=example,dc=org";
$ldap_server->dn_search_user = "cn=LDAPUserLookup,dc=MyDirectory";
$ldap_server->dn_search_user = "LDAPUserLookup@example.org"; - Active Directory specific syntax

If the directory is set up to allow read access without having to log on then just leave the user name and password blank (which will perform an "anonymous bind").

$ldap_server->dn_search_password Password corresponding to the account specified in $ldap_server->dn_search_user, which is used by the address book software to search the LDAP directory for a user's DN when logging in.

Example:
$ldap_server->dn_search_password = "password";

$ldap_server->add_user() Specifies the mapping between address book logins and the back-end directory when per-user authentication is enabled. (see Configuring Users and Permissions for further information.)
 
This setting can be repeated for however many user mappings need are needed.
 
Example:
$ldap_server->add_user("__ANONYMOUS__",
        array(
                "ldap_dn"=>"CN=ldap-browse,O=example",
                "ldap_password"=>"foobar",
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true
        ));
$ldap_server->add_user("__DEFAULT__",
        array(
                "allow_browse"=>true,
                "allow_search"=>true,
                "allow_view"=>true,
                "allow_create"=>true,
                "allow_edit"=>true,
                "allow_delete"=>true
        ));
(allows read-only access to anyone, log in by name in order to edit records)
$ldap_server->follow_referrals Causes the address book to attempt to follow LDAP referrals.
 
Referrals are used where the contents of the LDAP directory are divided between several servers, with a different section of the directory stored on each. This is normally used only in larger organizations. A referral is a message which indicates that the requested information is stored on a different server. If follow_referrals is set to true the Address Book will attempt to connect to the other server to retrieve the information.
 
Beware: This feature is currently experimental.
 
In Microsoft Active Directory, referrals are used where several domains have been joined into a "forest". As an alternative to using referrals, the LDAP Address Book can be set up to use the forest's Global Catalog (by connecting to an alternate LDAP service running on port 3268 - see description of $ldap_server above). Not all attributes are stored in the Global Catalog by default - for example job titles and department information. Missing attributes can be added to the Global Catalog using the "Active Directory Schema" admin tool.

Example:
$ldap_server->follow_referrals = true;

Search/Browse Directory Settings
$search_ldap_attrib This specifies which attributes (fields) get searched when a user searches the address book. Add to the list if you have specific requirements, e.g. if you want users to be able to search on a department name (department) or building (physicalDeliveryOfficeName).

Example:
$search_ldap_attrib = array("cn","mail","sn","displayName","company","title");

$search_ldap_filter Specifies the LDAP filter to be applied when searching through records in the directory. The token ___search_criteria___ will be replaced with an expression to search the attributes listed in $search_ldap_attrib for the string entered by the user.

Example:
$browse_ldap_filter = "(&(objectClass=person)___search_criteria___)";

$browse_ldap_filter Specifies the LDAP filter to be applied when browsing through records in the directory. This is normally set to objectClass=*, which allows all records in the directory to be displayed.

Example:
$browse_ldap_filter = "objectClass=*";

$search_result_columns Specifies the column layout to be used for displaying search results. Each column has three fields associated with it:
  • caption - Caption to appear in column heading
  • attrib - LDAP attribute to display
  • link_type - Whether and how to display the attribute as a hyperlink. This field can be ommitted if not used.

The special attribute sortableName will display constructed "sort-friendly" version of a personal name (Surname, Firstname) based on which LDAP attributes are populated. (Ideally sn and givenName if populated, otherwise falling back to displayName or cn.)

Example:
$search_result_columns = array(
        array("caption"=>"Name",                "attrib"=>"sortableName",       "link_type"=>"object"),
        array("caption"=>"E-Mail",              "attrib"=>"mail"),
        array("caption"=>"Office Phone",        "attrib"=>"telephoneNumber"),
        array("caption"=>"Organization",        "attrib"=>"company")
        );

The syntax "link_type"=>"object" indicates that values in the the name (sortableName) column should show as links to show more information about each object. It is recommended to place record names in the left-most column, shown as links.

$search_result_default_sort_order Specifies the default sort order for displaying search results. User can change the sort order by clicking a column header.

Example:
$search_result_default_sort_order = "sortableName";

$enable_search_suggestions Specifies whether search results from the directory should be the "suggested" as the user types in search terms. It may be more appropriate to disable this facility in large installations in order to reduce server load.

Example:
$enable_search_suggestions = true;

$lc_collate Specifies the collation locale (sorting language/region/script) to be used for browsing and displaying search results.

Example:
$lc_collate = "en_US";

$search_method Specifies the search result matching method to be used. This setting is optional, included to allow users to restore legacy search behavior should they wish. Allowed values are:
1
match anywhere in string (default search behavior)
2
match start of string only (behavior like versions 0.20 and earlier)

Example:
$search_method = 1;

Detailed Info View
$ldap_server->add_display_layout() Specifies the attributes to be shown in detailed entry view and how they should be laid out. See the section "Changing the layout and attributes shown for directory entries" above for further information.
 
Example:
// Display information about a printer in Active Directory

$ldap_server->add_display_layout("printQueue",array(
    array("section_name"=>"Shared Printer",
        "attributes"=>array(
            array("printerName",                    "Printer",              "printer.png"),
            array("location",                       "Location",             "address.png"),
            array("driverName",                     "Driver/Model",         "generic24.png"),
            array("description",                    "Description",          "description.png")
            )
        ),

    array("section_name"=>"Capabilities","width"=>"50%",
        "attributes"=>array(
            array("printColor",                     "Color Printing",       "generic24.png"),
            array("printStaplingSupported",         "Stapling",             "generic24.png"),
            array("printDuplexSupported",           "Double-Sided Printing","generic24.png"),
            array("printRate",                      "Printing Speed (PPM)", "generic24.png"),
            array("printMaxResolutionSupported",    "Max. Resolution (DPI)","generic24.png")
            )
        ),

    array("section_name"=>"Print Server","new_row"=>true,"colspan"=>2,
        "attributes"=>array(
            array("serverName",                     "Host Name",            "computer.png"),
            array("uNCName",                        "Printer UNC Path",     "domain24.png")
            )
        ),

    array("section_name"=>"Paper Available","new_row"=>true,"colspan"=>2,
        "attributes"=>array(
            array("printMediaReady")
            )
        )
    ));
Photo/Image Display Settings
$enable_search_browse_thumbnail Specifies whether thumbnail images should be displayed next to directory entries in browse/search results view (if available) instead of object class icons.

Example:
$enable_search_browse_thumbnail = true

$enable_ldap_path_thumbnail Specifies whether thumbnail images should be displayed in the detailed info view's "navigation path" (if available) instead of object class icons.

Example:
$enable_ldap_path_thumbnail = true

$thumbnail_image_size Size to which images should be scaled for use as thumbnails/icons.

Example:
$thumbnail_image_size = "24x24";

$photo_image_size Size to which images should be scaled for display in the detailed info view. Set to an empty string (or leave undefined) to disable scaling of these images.

Example:
$photo_image_size = "96x96";

Computer/Telephony Integration Settings
$phone_number_link_template Specifies if and how phone numbers should be displayed as clickable links (e.g. to support "click-to-dial" functionality). Leaving this setting blank (or not setting it at all) will display phone numbers as plain text rather than a link.

The token "___phone_number___" will be replaced with the actual phone number to be dialed.

Examples:

Enable click-to-dial support on many mobile phone web browsers:

$phone_number_link_template = "tel:___phone_number___";

Enable click-to-dial by calling Cisco WebDialer running on host cucm01:

$phone_number_link_template = "https://cucm01/webdialer/Webdialer?destination=___phone_number___";
$phone_number_link_target = "_blank";

$phone_number_link_target Specifies a value for a phone number link's "target" attribute. It may be useful to set this to "_blank" for certain click-to-dial software or if the address book is set up to run inside a HTML frame.

Example:
$phone_number_link_target = "_blank";

Data Export Settings
$exclude_logo_if_photo_present Specifies whether logo images (from the thumbnailLogo attribute) should be omitted when exporting as vCard if a photograph is also present. This may be useful when transferring records from the Address Book to Android devices.

Example:
$exclude_logo_if_photo_present = true;

Date and Time Display Settings
$date_format Specifies the format/layout for displaying attributes containing dates on an LDAP entry's "detailed info" page.

The following tokens (each consisting of % followed by a letter) used to describe the format/layout:

  • %a - An abbreviated textual representation of the day
  • %A - A full textual representation of the day
  • %d - Two-digit day of the month (with leading zeros)
  • %e - Day of the month, with a space preceding single digits. (Not implemented on Windows.)
  • %j - Day of the year, 3 digits with leading zeros
  • %u - ISO-8601 numeric representation of the day of the week
  • %w - Numeric representation of the day of the week
  • %U - Week number of the given year, starting with the first Sunday as the first week
  • %V - ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week
  • %W - A numeric representation of the week of the year, starting with the first Monday as the first week
  • %b - Abbreviated month name, based on the locale
  • %B - Full month name, based on the locale
  • %h - Abbreviated month name, based on the locale (an alias of %b)
  • %m - Two digit representation of the month
  • %C - Two digit representation of the century (year divided by 100, truncated to an integer)
  • %g - Two digit representation of the year going by ISO-8601:1988 standards (see %V)
  • %G - The full four-digit version of %g
  • %y - Two digit representation of the year
  • %Y - Four digit representation for the year
  • %D - Same as %m/%d/%y
  • %F - Same as %Y-%m-%d (commonly used in database date stamps)
  • %x - Preferred date representation based on locale (without the time)
  • %n - A newline character (\n)
  • %t - A Tab character (\t)
  • %% - A literal percentage character (%)

(information based on PHP manual)

Example:
$date_format = "%A %d %B %Y";

$date_time_format Specifies the format/layout for displaying attributes containing dates and times (timestamps) on an address book entry's "detailed info" page.

See the description of $date_format (above) for a list of tokens (each consisting of % followed by a letter) used to describe the format/layout. The following additional tokens may be used to describe the time:

  • %H - Two digit representation of the hour in 24-hour format
  • %k - Two digit representation of the hour in 24-hour format, with a space preceding single digits
  • %I - Two digit representation of the hour in 12-hour format
  • %l - Hour in 12-hour format, with a space preceding single digits
  • %M - Two digit representation of the minute
  • %p - Upper-case 'AM' or 'PM' based on the given time
  • %P - Lower-case 'am' or 'pm' based on the given time
  • %r - Same as %I:%M:%S %p
  • %R - Same as %H:%M
  • %S - Two digit representation of the second
  • %T - Same as %H:%M:%S
  • %X - Preferred time representation based on locale, without the date
  • %z - The time zone offset. Not implemented as described on Windows. See below for more information.
  • %Z - The time zone abbreviation. Not implemented as described on Windows. See below for more information.
  • %c - Preferred date and time stamp based on locale
  • %s - Unix Epoch Time timestamp (same as the time() function)

Example:
$date_time_format = "%A %d %B %Y %H:%M:%S";

$short_date_format Specifies a more compact format/layout for displaying attributes containing dates shown when browsing or searching the address book.

See the description of $date_format (above) for a list of the tokens (each consisting of % followed by a letter) used to describe the format/layout.

Example:
$short_date_format = "%d %b %Y";

$short_date_time_format Specifies a more compact format/layout for displaying attributes containing dates and times (timestamps) shown when browsing or searching the address book.

See the descriptions of $date_format and $date_time_format (above) for lists of the tokens (each consisting of % followed by a letter) used to describe the format/layout.

Example:
$short_date_time_format = "%d %b %Y %H:%M:%S";

Schema Configuration
$ldap_server->add_schema() Adds the contents of an additional schema file to the Address Book.

Example:
$ldap_server->add_schema("mozilla");

$ldap_server->add_object_class() Adds a new object class definition to the schema.

Example:

$ldap_server->add_object_class("container",array(
	"icon"=>"folder.png",
	"is_folder"=>true,
	"display_name"=>"Container",
	"can_create"=>true)
	);

$ldap_server->add_attribute_class() Adds a new attribute class definition to the schema.

Example:

$ldap_server->add_attribute_class("sshPublicKey",array(
	"data_type"=>"text_list",
	"display_name"=>"SSH Public Key")
	);

$ldap_server->modify_attribute_class() Modifies a setting associated with an attribute class definition. The setting will be added to the definition if not previously present.

Example:
$ldap_server->modify_attribute_class("mail","data_type","text_list");

$ldap_server->modify_object_class() Modifies a setting associated with an object class definition. The setting will be added to the definition if not previously present.

Example:
$ldap_server->modify_object_class("organizationalUnit","can_create",false);

$ldap_server->delete_object_class() Deletes an object class from the schema.

Example:
$ldap_server->delete_object_class("container");

$ldap_server->delete_attribute_class() Deletes an attribute class from the schema.

Example:
$ldap_server->delete_attribute_class("container");