Using SSH from a terminal, login as root to the virtual machine you have created for use as the LDAP provider, using the root password set at creation.
:~$ssh root@vm36.student.lab root@vm36.student.lab's password:NaNaKiNg
At the virtual machine prompt use pico to edit the /etc/hosts file to match:
127.0.0.1 localhost 10.80.3.36 vm36.student.lab vm36 # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
And save the file with <Ctrl>+<X>.
root@vm36:~#apt-get install ssh nmap
root@vm36:~#apt-get install slapd ldap-utils
Confirm that slapd is running using the command:
~# nmap -p 389 localhost
The response received should look like:
Starting Nmap 5.00 ( http://nmap.org ) at 2010-10-27 15:05 CEST Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1. Interesting ports on localhost (127.0.0.1): PORT STATE SERVICE 389/tcp open ldap Nmap done: 1 IP address (1 host up) scanned in 0.08 seconds
# 1. dn: cn=config changetype: modify replace: olcLogLevel olcLogLevel: stats # 2.1. dn: olcDatabase={1}hdb,cn=config changetype: modify add: olcDbIndex olcDbIndex: uid eq - # 2.2. add: olcDbIndex olcDbIndex: cn eq - # 2.3. add: olcDbIndex olcDbIndex: ou eq - # 2.4. add: olcDbIndex olcDbIndex: dc eq
~# ldapmodify -QY EXTERNAL -H ldapi:/// -f ~/olc-mod1.ldif
If the changes are implemented the screen should display:
modifying entry "cn=config" modifying entry "olcDatabase={1}hdb,cn=config" ~#
dn: ou=people,dc=student,dc=lab ou: people objectClass: organizationalUnit dn: ou=groups,dc=student,dc=lab ou: groups objectClass: organizationalUnit
~# ldapadd -cxWD cn=admin,dc=student,dc=lab -f ~/tree.ldif Enter LDAP Password:CaK30RD3aTH
The screen should display:
adding new entry "ou=people,dc=student,dc=lab" adding new entry "ou=groups,dc=student,dc=lab" ~#
Perform a test. Run an ldapsearch with an anonymous bind (no DN specified) to check that the new organizational units have indeed been added to the database. Using the command:
~#ldapsearch -xLLL
Check that the output looks like the following and does not contain any obvious errors:
~# ldapsearch -xLLL dn: dc=student,dc=lab objectClass: top objectClass: dcObject objectClass: organization o: student.lab dc: student dn: cn=admin,dc=student,dc=lab objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator dn: ou=people,dc=student,dc=lab ou: people objectClass: organizationalUnit dn: ou=groups,dc=student,dc=lab ou: groups objectClass: organizationalUnit ~#
dn: cn=genUsr,ou=groups,dc=student,dc=lab cn: genUsr gidNumber: 20000 objectClass: top objectClass: posixGroup dn: uid=genUsr,ou=people,dc=student,dc=lab uid: genUsr uidNumber: 20000 gidNumber: 20000 cn: Generic sn: User objectClass: top objectClass: person objectClass: posixAccount objectClass: shadowAccount loginShell: /bin/bash homeDirectory: /home/genUsr userPassword: Guest1
ldapadd -cxWD cn=admin,dc=student,dc=lab -f ~/genUsr.ldif
ldapsearch -xLLL uid=genUsr
dn: uid=genUsr,ou=people,dc=student,dc=lab uid: genUsr uidNumber: 20000 gidNumber: 20000 cn: General sn: User objectClass: top objectClass: person objectClass: posixAccount objectClass: shadowAccount loginShell: /bin/bash homeDirectory: /home/genUsr
It is possible to test authentication for a LDAP account by using the 'whoami' command:
ldapwhoami -xD uid=genUsr,ou=people,dc=student,dc=lab -w Guest1