Skip to content

Instantly share code, notes, and snippets.

@chrisdchristo
Created December 28, 2013 14:16
Show Gist options
  • Save chrisdchristo/8159950 to your computer and use it in GitHub Desktop.
Save chrisdchristo/8159950 to your computer and use it in GitHub Desktop.
101: PhpLdapAdmin

101: PhpLdapAdmin

https://mydomain.com:446/pla

sudo apt-get install phpldapadmin

By default, an apache phpldapadmin.conf file is placed in /etc/apache2/conf.d/phpldapadmin.conf which links a conf file in the phpldapadmin installation. Its is better to manage the various websites via ssl encrypted virtual hosts.

sudo mv /etc/apache2/conf.d/phpldapadmin /etc/apache2/sites-available/phpldapadmin
sudo nano /etc/apache2/sites-available/phpldapadmin
<VirtualHost *:446>
Alias /pla /usr/share/phpldapadmin/htdocs
DocumentRoot /usr/share/phpldapadmin/htdocs/

<Directory /usr/share/phpldapadmin/htdocs/>
    DirectoryIndex index.php
    Options +FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

    <IfModule mod_mime.c>

      <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
      </IfModule>

      <IfModule !mod_php5.c>
        <IfModule mod_actions.c>
          <IfModule mod_cgi.c>
            AddType application/x-httpd-php .php
            Action application/x-httpd-php /cgi-bin/php5
          </IfModule>
          <IfModule mod_cgid.c>
            AddType application/x-httpd-php .php
            Action application/x-httpd-php /cgi-bin/php5
           </IfModule>
        </IfModule>
      </IfModule>

    </IfModule>

</Directory>

SSLEngine on
SSLCACertificateFile /etc/ssl/custom/certs/official-www-mydomain-com-ad-inter.crt
SSLCertificateFile    /etc/ssl/custom/certs/official-www-mydomain-com.crt
SSLCertificateKeyFile /etc/ssl/custom/keys/official-www-mydomain-com.key
</VirtualHost>

First you'll need to get apache to listen to port 446 under SSL. Open the ports config file:

sudo nano /etc/apache2/ports.conf

and add the lines Listen 446 to both the mod_ssl and mod_gnutls modules.

<IfModule mod_ssl.c>
   ...
    Listen 446
</IfModule>

<IfModule mod_gnutls.c>
    ...
    Listen 446
</IfModule>

If you want remote access make sure you open the port 445 on your firewall. You then want to enable the website and restart the web server:

sudo a2ensite phpldapadmin
sudo /etc/init.d/apache2 restart

Finally, pla can be accessed by the following:

https://mydomain.com:446/pla

Editing the config file

Open up the file:

sudo nano /etc/phpldapadmin/config.php

and replace the following lines:

$servers->setValue('server','name','mydomain LDAP Server
$servers->setValue('server','host','ldap://n1.mydomain.com');
$servers->setValue('server','port',389);
$servers->setValue('server','base',array('dc##mydomain,dc##com'));
$servers->setValue('login','bind_id','cn##admin,dc##mydomain,dc##com');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment