Mock LDAP on Ubuntu 22 Open Ldap PHPLdapAdmin— with bug fix
Install OpenLdap
The package is name slapd
which stand for Stand alone Ldap
sudo apt-get update
sudo apt-get install slapd ldap-utils
Then config and follow the screen
sudo dpkg-reconfigure slapd
The important step here are
- Admin password
- Domain for example
example.com
will bedc=example,dc=com
Install and Config PHP Ldap Admin
You are good to go if you are on the Ubuntu 23.
** If you are on Ubuntu 22 (latest LTS version) you should skip this and follow the section below
sudo apt-get install phpldapadmin
Edit the file in /etc/phpldapadmin/config.php
Make sure the IP and DC is correct
$servers->setValue('server','base', array('dc=example,dc=com'));
$servers->setValue('server','host','127.0.0.1');
$config->custom->appearance['hide_template_warning'] = true;
Now you can access the screen in
http://<your_ip>/phpldapadmin
Then you can try adding Group and User
Expand the base and create the child entry
You can try on creating Posix Group then User
Then you can try to bind and query with the user / password created.
ldapsearch -x -H ldap://localhost:389 \
-D "cn=thisuser,dc=example,dc=com" \
-b "dc=example,dc=com" \
-W
Ubuntu 22.04 Issue
There is an issue in phpldapadmin that is not yet fixed in this LTS
Unrecognized error number: 8192: trim():
Passing null to parameter #1 ($string) of type string is deprecated
Then you can resolve it by purging and download the new pack
sudo apt-get purge phpldapadmin
wget http://archive.ubuntu.com/ubuntu/pool/universe/p/phpldapadmin/phpldapadmin_1.2.6.3-0.3_all.deb
dpkg -i phpldapadmin_1.2.6.3-0.3_all.deb
Difference between OpenLdap and Microsoft Active Directory Bind
- OpenLdap use DC=, CN= as bind DN
- Microsoft Active Directory use email as bind DN
So to test OpenLdap the command will be
# OpenLdap Query
ldapsearch -x -H ldap://localhost:389 \
-D "cn=thisuser,dc=example,dc=com" \
-b "dc=example,dc=com" \
-W
# On Microsoft below option is working but not in OpenLdap
...
-D "thisuser@example.com"
References
https://medium.com/analytics-vidhya/install-openldap-with-phpldapadmin-on-ubuntu-9e56e57f741e