So I made a tutorial after reading this post + another post + watching a few youtube videos and finally getting it down pat. Having an esxi server makes trail and error trivial time wise
https://www.freesoftwareservers.com/index.php/2016/07/13/install-ldap-phpldapadmin-ubuntu-14-04/
https://youtu.be/BU48SA2uv1s
Hostname : ldap.freesoftwareservers.com
[DOMAIN] : freesoftwareservers
[LDAPIP] : 192.168.1.200
Copy Text then Find & Replace
[LDAPIP] = Ldap Servers IP Address
[DOMAIN] = Root domain without .com IE: freesoftwareservers
[COMNETORG] = .com or .net or .org or .whatever
sudo su
apt-get update
apt-get install -y apache2 slapd ldap-utils phpldapadmin
sh -c 'echo "BASE dc=[DOMAIN],dc=[COMNETORG]\nURI ldap://[LDAPIP]" >> /etc/ldap/ldap.conf'
dpkg-reconfigure slapd
Enter the Following :
NO
[DOMAIN].[COMNETORG]
[DOMAIN]
Admin PWD (Note this is the Ldap User "Admin" PWD, doesn't have to be root/sudo users PWD)
Admin PWD
HDB
NO
YES
NO
Replace all instances of “127.0.01” with [LDAPIP] & replace all instances of dc=example with dc=[DOMAIN]
sed -i -e 's/127.0.0.1/[LDAPIP]/g' /etc/phpldapadmin/config.php
sed -i -e 's/dc=example/dc=[DOMAIN]/g' /etc/phpldapadmin/config.php
Not using .com? Then run the following as well
sed -i -e 's/dc=com/dc=[COMNETORG]/g' /etc/phpldapadmin/config.php
Change default shell to /bin/bash and default home dir to /home/$username :
nano /etc/phpldapadmin/templates/creation/posixAccount.xml
<attribute id="homeDirectory">
<display>Home directory</display>
<!-- <onchange>=autoFill(homeDirectory;/home/%gidNumber|0-0/T%/%uid|3-%)</onchange> -->
<order>8</order>
<page>1</page>
</attribute>
<attribute id="loginShell">
<display>Login shell</display>
<order>9</order>
<page>1</page>
<!-- <value><![CDATA[=php.PickList(/;(&(objectClass=posixAccount));loginShell;%loginShell%;;;;loginShell)]]></value> -->
<type>select</type>
<value id="/bin/sh">/bin/sh</value>
<value id="/bin/csh">/bin/csh</value>
<value id="/bin/tsh">/bin/tsh</value>
<value id="/bin/bash">/bin/bash</value>
</attribute>
Adding User causes weird PWD Glitch :
sed -i -e 's/password_hash/password_hash_custom/g' /usr/share/phpldapadmin/lib/TemplateRender.php
Using this in a Dedicated VM? Redirect the root domain.com to domain.com/phpldapadmin via:
sh -c 'echo "RedirectMatch ^/$ /phpldapadmin/" >> /etc/apache2/apache2.conf'
service apache2 restart
Open UFW
ufw allow 389
ufw allow 80
Enable Public Key Attribute :
cat << EOL >~/openssh-lpk.ldif
dn: cn=openssh-lpk,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: openssh-lpk
olcAttributeTypes: ( 1.3.6.1.4.1.24552.500.1.1.1.13 NAME 'sshPublicKey'
DESC 'MANDATORY: OpenSSH Public key'
EQUALITY octetStringMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
olcObjectClasses: ( 1.3.6.1.4.1.24552.500.1.1.2.0 NAME 'ldapPublicKey' SUP top AUXILIARY
DESC 'MANDATORY: OpenSSH LPK objectclass'
MAY ( sshPublicKey $ uid )
)
EOL
Add ldif for RSA Key Support :
ldapadd -Y EXTERNAL -H ldapi:/// -f ~/openssh-lpk.ldif
Check everything is working :
ldapsearch -x
If you don’t get something similar, its not working!
root@ldap:# ldapsearch -x
# extended LDIF
#
# LDAPv3
# base <dc=freesoftwareservers,dc=com> (default) with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# freesoftwareservers.com
dn: dc=freesoftwareservers,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: FreeSoftwareServers
dc: freesoftwareservers
# admin, freesoftwareservers.com
dn: cn=admin,dc=freesoftwareservers,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
# search result
search: 2
result: 0 Success
# numResponses: 3
# numEntries: 2