LDAP Server on Ubuntu |
Server Training - Server Management |
Install on Ubuntu If you want to run LDAP server on Ubuntu you will need to install several programs. slapd and ldap-utils. Use apt-get as root or with sudo for these two programs and it will also install all the dependencies. # apt-get install slapd ldap-utils This series of articles will help you understand the benefits of LDAP as well as implementation of LDAP.
After the initial password that you create, whenever you need to create passwords use the slappasswd application which will create an encrypted password for you. Create a root Password: # slappasswd New password: Re-enter new password: {SSHA}k1wLLf+cCUArjAt2BuFGe6OYdSiayIZd For example, if you needed to create a new password for admin user you would use slappasswd and then copy the password that was created and insert it in your /etc/ldap/slapd.conf. # rootdn directive for specifying a superuser on the database. This is needed # for syncrepl. rootdn "cn=admin,dc=example,dc=com" rootpw {SSHA}k1wLLf+cCUArjAt2BuFGe6OYdSiayIZd
Preparation to Start LDAP
Before starting LDAP you must set your database type for Database #1, the suffix for your domain, set your rootdn, rootdn password and the directory location for you files. Note that example.com is the domain that is used here. Edit /etc/ldap/slapd.conf and make the necessary changes. database hdb suffix "dc=example,dc=com" rootdn "cn=admin,dc=example,dc=com" rootpw {SSHA}k1wLLf+cCUArjAt2BuFGe6OYdSiayIZd directory "/var/lib/ldap" You will also need to edit the BASE location in your ldap.conf file. Edit /etc/ldap/ldap.conf BASE dc=example,dc=com Add Information to the Tree In order to use slapadd, slapcat or slapindex the directory must be stopped to preserve the database integrity. Here is the command: /etc/init.d/slapd stop Add your init.ltif # rm -rf /var/lib/ldap/* Configure your init.ltif Here is the init.ltif File Create this file so you may add the content for your system. objectClass: dcObject objectClass: organizationalUnit dc: example ou: Example Dot Com
dn: cn=admin,dc=example,dc=com objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator userPassword: {SSHA}k1wLLf+cCUArjAt2BuFGe6OYdSiayIZd
dn: ou=people,dc=example,dc=com objectClass: organizationalUnit ou: people
dn: ou=groups,dc=example,dc=com objectClass: organizationalUnit ou: groups
dn: uid=fsmith,ou=people,dc=example,dc=com objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount uid: fsmith sn: Smith givenName: Fred cn: Fred Smith displayName: Fred Smith uidNumber: 1001 gidNumber: 1001 userPassword: {SSHA}w5tiDXpVXOWr4cCujbrqUNdlUX+wYPY0 gecos: Fred Smith loginShell: /bin/bash homeDirectory: /home/fsmith shadowExpire: -1 shadowFlag: 0 shadowWarning: 7 shadowMin: 8 shadowMax: 999999 shadowLastChange: 10877 mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it initials: FS Note that this program must be run as root, however, the server, due to security concerns, runs as the ldap user. Therefore, once you add an ldif file you must change the ownership of the /var/lib/ldap directory. Change Permissions
Modify tcp_wrappers Edit tcp_wrappers /etc/hosts.allow SSHD: ALL SLAPD: ALL Start the LDAP Server # /etc/init.d/slapd start Note that this program must be run as root, however, the server, due to security concerns, runs as the ldap user. Therefore, once you add an ldif file you must change the ownership of the /var/lib/ldap directory. Change Permissions Verify that the server started by checking port 389 which is the default port. netstat -aunt You should see the port listening like so. Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN Test Your Database
-x perform simple bind (do not use SASL authentication)
Example Output:
ldapsearch -xLLL -b "dc=example,dc=com" '(objectclass=*)' dn: dc=example,dc=com objectClass: dcObject objectClass: organizationalUnit dc: example ou: Example Dot Com
dn: cn=admin,dc=example,dc=com objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator
dn: ou=people,dc=example,dc=com objectClass: organizationalUnit ou: people
dn: ou=groups,dc=example,dc=com objectClass: organizationalUnit ou: groups
dn: uid=fsmith,ou=people,dc=example,dc=com objectClass: inetOrgPerson objectClass: posixAccount objectClass: shadowAccount uid: fsmith sn: Smith givenName: Fred cn: Fred Smith displayName: Fred Smith uidNumber: 1001 gidNumber: 1001 gecos: Fred Smith loginShell: /bin/bash homeDirectory: /home/fsmith shadowExpire: -1 shadowFlag: 0 shadowWarning: 7 shadowMin: 8 shadowMax: 999999 mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it initials: FS
Copyright CyberMontana Inc. and BeginLinux.com All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874
|