LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-08-2009, 05:27 AM   #1
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Rep: Reputation: 0
openldap server: ldif problem


Hi
when i try to run this command i get an error
Code:
ldapadd -h localhost -x -D "cn=Manager,dc=zlango,dc=com" -W -f base.ldif 
Enter LDAP Password: 
ldapadd: attributeDescription "dn": (possible missing newline after line 6 of entry "dc=zlango,dc=com"?)
ldapadd: attributeDescription "dn": (possible missing newline after line 9 of entry "dc=zlango,dc=com"?)
ldapadd: attributeDescription "dn": (possible missing newline after line 12 of entry "dc=zlango,dc=com"?)
adding new entry "dc=zlango,dc=com"
ldap_add: Type or value exists (20)
	additional info: objectClass: value #3 provided more than once
can anyone help ??????

this is my slapd.conf:
Code:
#
# 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/lib64/openldap
# moduleload	back_bdb.la
# moduleload	back_ldap.la
# moduleload	back_ldbm.la
# moduleload	back_passwd.la
# moduleload	back_shell.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=zlango,dc=com"
rootdn		"cn=Manager,dc=zlango,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw			{MD5}3OwCycMA61rgH7kP4G7fuw==

# 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

# 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=Manager,dc=zlango,dc=com" write
    by anonymous auth
    by * none
 
access to *
    by dn="cn=Manager,dc=zlango,dc=com" write
    by self write
    by * read
and this is my ldif file:
Code:
dn: dc=zlango,dc=com
o: zlango Organization
dc: zlango
description: zlango LDAP server
#objectClass: top
objectClass: dcObject
objectClass: organization
 
dn: cn=Manager,dc=zlango,dc=com
objectClass: organizationalRole
cn: manager
 
dn: ou=People,dc=zlango,dc=com
objectClass: organizationalUnit
ou: People
 
dn: ou=Group,dc=zlango,dc=com
objectClass: organizationalUnit
ou: Group
thanks.

Last edited by OrC82; 02-08-2009 at 05:32 AM.
 
Old 02-08-2009, 02:11 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You should modify the ldif like this:
Code:
dn: dc=zlango,dc=com
dc: zlango
description: zlango LDAP server
objectClass: dcObject
objectClass: organization
o: zlango Organization
 
dn: ou=People, dc=zlango,dc=com
ou: People
objectClass: organizationalUnit
 
dn: ou=Group,dc=zlango,dc=com
ou: Group
objectClass: organizationalUnit
Note that it's not necessary to add the rootdn defined in slapd.conf (dn: cn=Manager,dc=zlango,dc=com) in ldap. It's used just for administering the server.
Take a look here for details about the ldif structure.

Regards
 
Old 02-09-2009, 05:35 AM   #3
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Hi bathory, thank you very much.
i wrote a nice bash script to create a new user to the LDAP server via migration tolls and it work fine
Code:
#!/bin/bash
# add a user to Linux system
if [ $(id -u) -eq 0 ]; then
        read -p "Enter username : " username
        read -s -p "Enter password : " password
        egrep "^$username" /etc/passwd >/dev/null
        if [ $? -eq 0 ]; then
                echo "$username exists!"
                exit 1
        else
                pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
                useradd -m -p $pass $username
                [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
        fi
else
        echo "Only root may add a user to the system"
        exit 2
fi

# create files for adding user and group to LDAP Server
cd /root
grep ^$username /etc/passwd > passwd
grep ^$username /etc/group > group
/usr/share/openldap/migration/migrate_passwd.p passwd > passwd.ldif
/usr/share/openldap/migration/migrate_group.p group > group.ldif

# add user and group to LDAP Server
ldapadd -h localhost -x -D "cn=Manager,dc=zlango,dc=com" -W -f passwd.ldif
ldapadd -h localhost -x -D "cn=Manager,dc=zlango,dc=com" -W -f group.ldif
i have a question about permissions
as I understand the following lines in slapd.conf are configure the permission on the clients.
Code:
access to attrs=userPassword
    by self write
    by dn="cn=Manager,dc=zlango,dc=com" write
    by anonymous auth
    by * none
 
access to *
    by dn="cn=Manager,dc=zlango,dc=com" write
    by self write
    by * read
how can i set different permissions to users ?

Regards.
 
Old 02-09-2009, 05:55 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You can take a look at these examples, but I think it's better to read about setting ACLs in the same page, just before the examples.

Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LDIF file in OpenLDAP bkcreddy17 Linux - Newbie 2 01-15-2009 06:36 AM
Wierd dependency problem with openldap-server package Akhran Fedora 1 02-15-2006 07:38 AM
openldap ldif file problem iluvatar Linux - Software 3 07-31-2005 06:57 PM
Problem importing LDIF file into OpenLDAP database cboxall Linux - Newbie 1 06-17-2005 09:51 AM
Facing problem while configuring OpenLDAP server shanu Linux - Software 1 03-13-2005 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration