cancel
Showing results for 
Search instead for 
Did you mean: 

ldap for cent os

taksheel
Occasional Contributor

ldap for cent os

i am a new user to LDAP.
i installed following ldap version on my centos server.
openldap-devel-2.3.43-12.el5_5.3
python-ldap-2.2.0-2.1
ldapjdk-4.18-2jpp.3.el5
openldap-clients-2.3.43-12.el5_5.3
php-ldap-5.1.6-27.el5
openldap-2.3.43-12.el5_5.3
openldap-servers-2.3.43-12.el5_5.3
nss_ldap-253-25.el5


i configured slapd.conf and below i am pasting details of the slapd.conf
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema

# Allow LDAPv2 client connections. This is NOT the default.
allow bind_v2

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral ldap://root.openldap.org

pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args

# Load dynamic backend modules:
# modulepath /usr/lib/openldap

# Modules available in openldap-servers-overlays RPM package
# Module syncprov.la is now statically linked with slapd and there
# is no need to load it here
# moduleload accesslog.la
# moduleload auditlog.la
# moduleload denyop.la
# moduleload dyngroup.la
# moduleload dynlist.la
# moduleload lastmod.la
# moduleload pcache.la
# moduleload ppolicy.la
# moduleload refint.la
# moduleload retcode.la
# moduleload rwm.la
# moduleload smbk5pwd.la
# moduleload translucent.la
# moduleload unique.la
# moduleload valsort.la

# modules available in openldap-servers-sql RPM package:
# moduleload back_sql.la

# The next three lines allow use of TLS for encrypting connections using a
# dummy test certificate which you can generate by changing to
# /etc/pki/tls/certs, running "make slapd.pem", and fixing permissions on
# slapd.pem so that the ldap user or group can read it. Your client software
# may balk at self-signed certificates, however.
# TLSCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
# TLSCertificateFile /etc/pki/tls/certs/slapd.pem
# TLSCertificateKeyFile /etc/pki/tls/certs/slapd.pem

# Sample security restrictions
# Require integrity protection (prevent hijacking)
# Require 112-bit (3DES or better) encryption for updates
# Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
# Root DSE: allow anyone to read it
# Subschema (sub)entry DSE: allow anyone to read it
# Other DSEs:
# Allow self write access
# Allow authenticated users read access
# Allow anonymous users to authenticate
# Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
# by self write
# by users read
# by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn. (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!

#######################################################################
# ldbm and/or bdb database definitions
#######################################################################

database bdb
suffix dc=emoss,dc=world
rootdn cn=root,dc=emoss,dc=world

# Cleartext passwords, especially for the rootdn, should
# be avoided. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
#rootpw secret
# rootpw {crypt}ijFYNcSNctBYg
rootpw {SSHA}ZKkYc8k8J7pdP2DAUhtnfG8DDDjKVDFL

# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /var/lib/ldap

# Indices to maintain for this database
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub

# DB_CONFIG Settings - For SleepyCat Berkeley DB
dbconfig set_cachesize 0 10485760 0
dbconfig set_lg_regionmax 262144
dbconfig set_lg_bsize 2097152

# Replicas of this database
#replogfile /var/lib/ldap/openldap-master-replog
#replica host=ldap-1.example.com:389 starttls=critical
# bindmethod=sasl saslmech=GSSAPI
# authcId=host/ldap-master.example.com@EXAMPLE.COM

access to attrs=userPassword
by self write
by dn="cn=root,dc=emoss,dc=world" write
by anonymous auth
by * none

access to *
by dn="cn=root,dc=emoss,dc=world" write
by self write
by * read




i created base.ldif file

dn: dc=emoss,dc=world
objectclass: top
objectclass: organization
o: emoss company
dc: emoss

dn: ou=Group,dc=emoss,dc=world
ou: Group
objectClass: top
objectClass: organizationalUnit

dn: ou=People,dc=emoss,dc=world
ou: People
objectClass: top
objectClass: organizationalUnit

dn: ou=Services,dc=emoss,dc=world
ou: Services
objectClass: top
objectClass: organizationalUnit

after creation of base.ldif file i typed bellow command for creating entry

ldapadd -a -W -x -D "cn=root,dc=emoss,dc=world" -f base.ldif
Enter LDAP Password:


I try to add a entry using ldapadd ,but it give the
following error.

adding new entry "dc=emoss,dc=world"
ldapadd: Object class violation (65)
additional info: attribute 'dc' not allowed


Where am i going wrong?
could help pls.


Advance Thanks

1 REPLY
Reiner Rottmann
Frequent Advisor

Re: ldap for cent os

You are referencing the domain component emoss that is not declared as a domain in your base ldif.

Here is a working base.ldif:

# extended LDIF
#
# LDAPv3
# base (default) with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# test.example.com
dn: dc=test,dc=example,dc=com
dc: test
objectClass: top
objectClass: domain

# Hosts, test.example.com
dn: ou=Hosts,dc=test,dc=example,dc=com
ou: Hosts
objectClass: top
objectClass: organizationalUnit

# Rpc, test.example.com
dn: ou=Rpc,dc=test,dc=example,dc=com
ou: Rpc
objectClass: top
objectClass: organizationalUnit

# Services, test.example.com
dn: ou=Services,dc=test,dc=example,dc=com
ou: Services
objectClass: top
objectClass: organizationalUnit

# netgroup.byuser, test.example.com
dn: nisMapName=netgroup.byuser,dc=test,dc=example,dc=com
nisMapName: netgroup.byuser
objectClass: top
objectClass: nisMap

# Mounts, test.example.com
dn: ou=Mounts,dc=test,dc=example,dc=com
ou: Mounts
objectClass: top
objectClass: organizationalUnit

# Networks, test.example.com
dn: ou=Networks,dc=test,dc=example,dc=com
ou: Networks
objectClass: top
objectClass: organizationalUnit

# People, test.example.com
dn: ou=People,dc=test,dc=example,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit

# Group, test.example.com
dn: ou=Group,dc=test,dc=example,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit

# Netgroup, test.example.com
dn: ou=Netgroup,dc=test,dc=example,dc=com
ou: Netgroup
objectClass: top
objectClass: organizationalUnit

# Protocols, test.example.com
dn: ou=Protocols,dc=test,dc=example,dc=com
ou: Protocols
objectClass: top
objectClass: organizationalUnit

# Aliases, test.example.com
dn: ou=Aliases,dc=test,dc=example,dc=com
ou: Aliases
objectClass: top
objectClass: organizationalUnit

# netgroup.byhost, test.example.com
dn: nisMapName=netgroup.byhost,dc=test,dc=example,dc=com
nisMapName: netgroup.byhost
objectClass: top
objectClass: nisMap

# jdoe, People, test.example.com
dn: uid=jdoe,ou=People,dc=test,dc=example,dc=com
uid: jdoe
cn: jdoe
givenName: John
sn: Doe
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
shadowLastChange: 14830
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 49064
gidNumber: 49064
mail: email@example.com
homeDirectory: /home/jdoe
userPassword:: e1NTSEF9amNZaHBKdTVYTSswRVIvYmpnNDFnd0kweXJ1a2RJUkU=