In Oracle VM Virtualbox I installed a fresh new copy of Ubuntu Server 14.04.1 64 bit version, with OpenSSH installed as well. Steps I done:
sudo apt-get install slapd ldap-utilsnano /etc/ldap/ldap.confHere I enteredBASE dc=elemer,dc=localURI ldap://192.168.0.14sudo apt-get install phpldapadminsudo nano /etc/phpldapadmin/config.phpand replaced all the "dc=example,dc=com" with "dc=elemer,dc=local"From the physical machine I bring up a webbrowser and type in 192.168.0.14/phpldapadmin It brings up the webpage and I type in my password (I set the LDAP password the same as the root).
LDAP laughs at me and says
"Unable to connect to LDAP server My LDAP Server
Error: Invalid credentials (49) for user
Failed to Authenticate to server
Invalid Username or Password"
The password is deffinetly right, I even created other virtual machines and repeated the process from scrath, used different approach at times but never managed to get it right.
If I run
ldapsearch -xit gives me: "Result: 32 No such objectIf I run
ldapaddand put in my password it says:
ldap_sasl_interactive_bind_s: INvalid credentials (49) additional info: SASL(-13): user not found: no secret in database
ldapsearch -x -LLL -H ldap:/// -b dc=example,dc=com dnwill giveNo such object (32)
5 Answers
So first of all ubuntu manage to create a long how to () about LDAP which omits an important phase:
You would have to run sudo dpkg-reconfigure slapd after you installed slapd and select : NO - your.domain.com - Organisation name - password - password - HDB - YES - YES - NO
I found the solution at Where is the dc=example,dc=com ldap dit?
Thank's for muru
2Edit: Apparantly this is a very wide spread issue and it has been reported in many other forums without a viable soloution. while ago I solved and reported the soloution here but after awhile when I wanted to redo the steps I reslised that i can't replicate sucessfully. so after some try and error again I succeed so I will put the instructions here, this time not omting any details. hopefully it helps. before starting the steps please make sure you have the IP address of your maching (e.g. using ifconfig, for example 192.168.33.10)
knowing/changing your hostname: open the file
/etc/hostname. you may delete everything there and replace it with your domain (e.g.myserver.org).installing OpenLDAP packages: you need 3 packages
slapd,ldap-utilsandphpldapadmin. installingslapdyou will be asked to enter admin password.configuring OpenLDAP: open
/etc/ldap/ldap.confuncomment the lines below (remove the # from the beginning of the lines)BASE dc=example,dc=com
URI ldap://ldap.example.com ldap://ldap-master.example.com:666
and change them to
BASE dc=myserver,dc=org
URI ldap://192.168.33.10 ldap://192.168.33.10:666
please remember that you have to replace the example IP
192.168.33.10with your IP adress.configuring phpldapadmin: open
/etc/phpldapadmin/config.phpin editor. Look for the lines having$servers->setValue, change127.0.0.1to the server IP address. change allexamples andcoms to the terms you have set in step aReconfigure the OpenLDAP Server: you need to Reconfigure the OpenLDAP Server (I don't know why really!)
sudo dpkg-reconfigure slapdthen select :NO->myserver.com->OrganisationName->password->password->HDB->NO->YES->NOthe problem should be solved by now. but when you go forward there is another problem as described here in this post. you can solve it by the instructions in the link
I should thanks Anandd Nayyar and refer to his youtube video which helped me a lot to solve these issues.
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
Hostname : ldap.freesoftwareservers.com
[DOMAIN] : freesoftwareservers
[LDAPIP] : 192.168.1.200Copy 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 slapdEnter 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
NOReplace 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.phpNot using .com? Then run the following as well
sed -i -e 's/dc=com/dc=[COMNETORG]/g' /etc/phpldapadmin/config.phpChange default shell to /bin/bash and default home dir to /home/$username :
nano /etc/phpldapadmin/templates/creation/posixAccount.xml
<attribute> <display>Home directory</display> <!-- <onchange>=autoFill(homeDirectory;/home/%gidNumber|0-0/T%/%uid|3-%)</onchange> --> <order>8</order> <page>1</page>
</attribute>
<attribute> <display>Login shell</display> <order>9</order> <page>1</page> <!-- <value><![CDATA[=php.PickList(/;(&(objectClass=posixAccount));loginShell;%loginShell%;;;;loginShell)]]></value> --> <type>select</type> <value>/bin/sh</value> <value>/bin/csh</value> <value>/bin/tsh</value> <value>/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.phpUsing this in a Dedicated VM? Redirect the root domain.com to via:
sh -c 'echo "RedirectMatch ^/$ /phpldapadmin/" >> /etc/apache2/apache2.conf'
service apache2 restartOpen UFW
ufw allow 389
ufw allow 80Enable 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 ) )
EOLAdd ldif for RSA Key Support :
ldapadd -Y EXTERNAL -H ldapi:/// -f ~/openssh-lpk.ldifCheck everything is working :
ldapsearch -xIf 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 After installing a full package OpenLdap, I noticed that the process doesn't restart correctly after a service slapd restart.
You need to find the process by running the command
sudo ps -aux | grep [s]lapdand then kill it
kill -9 <PID>and sudo service slapd start. Everything worked for me after that.
I followed these steps. This worked for me.
First remove all the packages (all means ldap packages you have installed) by using sudo apt-get remove <package> then follow these steps:
Step 1: Install OpenLDAP
sudo apt-get install slapd ldap-utils- Give the administrator password/root password
- Re-enter the password of administrator/root
Step 2: Configure OpenLDAP
Open the file
/etc/ldap/ldap.confin GeditMake sure the file looks as follows:
#LDAP Defaults #See ldap.conf for details #This file should be world readable but not world writable. BASE dc=ldap,dc=com URI ldap://localhost:389 12 15 never #TLS certificates (needed for GnuTLS) TLS_CACERT /etc/ssl/certs/ca-certificates.crt*Save the file and exit
Step 3: Reconfigure the slapd with the updated values
sudo dpkg-reconfigure slapd- Select "No" and Press Enter
- Enter the DNS Domain Name
ldap.com - Enter the Organization Name: Enter any name, e.g. Anagh Software
- Enter the LDAP Admin Password
- Select the Backend Database
- Choose the Default Only
- On the next screen select "No"
- Click Yes to Move the Old Database
- Select "No" under LDAPv2 Protocol
Step 4: Test the openLDAP
ldapsearch -xPART-B LDAP Server Administration
Install
phpldapadminpackagesudo apt-get install phpldapadminsudo gedit /etc/phpldapadmin/config.phpEdit the following values
Set your LDAP server name
$servers->setValue('server','name', Anagh LDAP Server');Set your LDAP server IP address
$servers->setValue('server','host','IP-Address');Set Server domain name
$servers->setValue('server','base',array('dc=ldap,dc=com'));Set Server domain name again
$servers->setValue('login','bind_id','cn=admin,dc=ldap,dc=com');
The below line will be commented. Uncomment it and then set it to true
$config->custom->appearance['hide_template_warning'] = true;Save and exit the file
Restart apache2
Open web browser
Then IP-Address/phpldapadmin