Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.