System information

With the file created, we can add the user to our LDAP server:
$ sudo ldapadd -x -D cn=admin,dc=shifteight,dc=org -f astusers.ldif -W
Enter LDAP Password:
adding new entry "uid=rbryant,ou=people,dc=shifteight,dc=org"
Our user has now been imported into LDAP. The next step is to configure Asterisk to
connect to the LDAP server and allow users to authenticate and register their phones.
Compiling LDAP Support into Asterisk
With our OpenLDAP server configured and the schema imported, we need to install
the dependencies for Asterisk and compile the res_config_ldap module. This module
is the key that will allow us to configure Asterisk realtime for accessing our peers
via LDAP.
Once we’ve installed the dependency, we need to rerun the ./configure script inside the
Asterisk source directory, then verify that the res_config_ldap module is selected. Then
we can run make install to compile and install the new module.
Ubuntu dependencies
On Ubuntu, we need to install the openldap-dev package to provide the dependency
for the res_config_ldap module:
$ sudo apt-get install openldap-dev
CentOS dependencies
On CentOS, we need to install the openldap-devel package to provide the dependency
for the res_config_ldap module:
$ sudo yum install openldap-devel
Configuring Asterisk for LDAP Support
Now that we’ve configured our LDAP server and installed the res_config_ldap module,
we need to configure Asterisk to support loading of peers from LDAP. To do this, we
need to configure the res_ldap.conf file to connect to the LDAP server and the extcon-
fig.conf file to tell Asterisk what information to get from the LDAP server, and how.
Once that is done, we can configure any remaining module configuration files, such as
sip.conf, iax.conf, voicemail.conf, and so on, where appropriate. In our example we’ll
be configuring Asterisk to load our SIP peers from realtime using the LDAP server as
our database.
Configuring res_ldap.conf
The res_ldap.conf.sample file is a good place to start because it contains a good set of
templates. At the top of the file, though, under the [_general] section, we need to
LDAP Integration | 437