Tuesday, August 18, 2009

LDAP Configuration

1) Sample of /etc/openldap/slapd. conf

include /etc/openldap/schema /core.schema
include /etc/openldap/schema /cosine.schema
include /etc/openldap/schema /inetorgperson.schem a
#include /etc/openldap/schema /samba.schema
include /etc/openldap/schema /nis.schema
include /etc/openldap/schema /redhat/autofs.schem a
# This confirms that these schemas are there for us and will not say database schema not present message.
schemacheck on

allow bind_v2
pidfile /var/run/slapd.pid

database ldbm
suffix "dc=index,dc=com"
rootdn "cn=Manager,dc=inde x,dc=com"
rootpw {SSHA}LNmVAsdffdsaaa aswqq
dbcachesize 100000
directory /var/lib/ldap
index objectClass eq,pres
index ou,cn,mail,surname,g ivenname eq,pres,sub
index uidNumber,gidNumber, loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEnt ry eq,pres,sub

2) Now configure /etc/openldap/ldap.c onf

HOST 127.0.0.1
BASE dc=index,dc=com

3) Now configure /etc/ldap.conf

host 127.0.0.1
base dc=index,dc=com
rootbinddn cn=manager,dc=index, dc=com
port 389
ssl no
pam_password md5

4) Now start ldap service and issue this command

ldapsearch -x -b 'dc=index,dc=com' '(objectClass=x)'

This will show the message
# extended LDIF
#
#LDAP v3
#base with scop.sub
#filter:(objectClass =x)
.....

5) There are other type of commands which should be used only after stopping ldap service. These are slapadd,slapcat and slapindex.

For eg if you want to populate ldbm first stop service

/etc/init.d/slapd stop
/usr/sbin/slapadd -V < /home/ullas_sample.l dif
/usr/sbin/slapindex -V
/etc/init.d/slapd start

6) To backup LDAP first stop slapd. Now issue command

/usr/sbin/slapcat > /tmp/backup.ldif

7) To search

/usr/sbin/ldapsearch -x cn=admin

8) To add data to database from command prompt

ldapadd -f ullas_sample.ldif -x -D "cn=Manager,dc=inde x,dc=com" -w password

This will add data from file ullas_sample.ldif to database.

9) Sample of ullas_sample.ldif

dn: dc=index,dc=com
objectclass: dcObject
objectclass: organization
o: e-commodities ltd
dc: index

dn: cn=Manager,dc=index, dc=com
objectclass: organizationalRole
cn: Manager

No comments: