[Date Prev][Date Next] [Chronological] [Thread] [Top]

A Question about ldapadd,ldapsearch!!!!



Hi,all:

I have some questions about ldapadd and ldapsearch, I only want to test whether my openldap works well!

So I edit two LDIFs, example.ldif and testdata.ldif as follows:

1.example.ldif

dn: dc=example,dc=com
objectclass: dcObject
objectclass: organization
o: Example Company
dc: example

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

2.testdata.ldif

dn:o=Acme,c=US
objectclass:organization
o:Acme

dn:ou=Managers,o=Acme,c=US
objectclass:organizationalUnit
ou:Managers

dn:cn=Jason H. Smith,ou=Managers,o=Acme,c=US
objectclass:inetOrgPerson
cn:Jason H. Smith
sn:Smith
telephoneNumber:111-222-9999
mail:headhauncho@acme.com

dn:ou=Employee,o=Acme,c=US
objectclass:organizationalUnit
ou:Employees

dn:cn=Ray D. Jones,ou=Employees,o=Acme,c=US
objectclass:inetOrgPerson
cn:Ray D. Jones
sn:Jones
telephoneNumber:444-555-8888
mail:jonesrd@acme.com
localityName:Houston

dn:cn=Eric S. Woods,ou=Employees,o=Acme,c=US
objectclass:inetOrgPerson
cn:Eric S. Woods
sn:Woods
telephoneNumber:444-555-6666
mail:woodses@acme.com
localityName:Houston

And I type the command one by one as follows:

1 My slapd.conf's config:
#######################################################################
# ldbm database definitions
#######################################################################

database        ldbm
suffix          "dc=example,dc=com"
rootdn          "cn=root,dc=example,dc=com"
#suffix         "o=Acme,c=US"
#rootdn         "cn=root,o=Acme,c=US"
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw          xjtu
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd/tools. Mode 700 recommended.
directory       /usr/local/var/openldap-ldbm

2
[root@NsfcServer openldap]# ldapsearch -x -b '' -s base '(objectclass=*)' naming
Contexts
version: 2

#
# filter: (objectclass=*)
# requesting: namingContexts
#

#
dn:
namingContexts: dc=example,dc=com

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

3 Have trouble at this time:
[root@NsfcServer openldap]# ldapadd -x -D "cn=Manager,dc=example,dc=com" -W -f /
home/xdw/example.ldif
Enter LDAP Password:
ldap_bind: Invalid credentials

~~~~~~~~~~~~~~~~~~~~~~~

4 Retry and use 'cn=root', still have problem
[root@NsfcServer openldap]# ldapadd -x -D "cn=root,dc=example,dc=com" -W -f /hom
e/xdw/example.ldif
Enter LDAP Password:
adding new entry "dc=example,dc=com "
ldap_add: Invalid syntax
        additional info: objectclass: value #0 invalid per syntax

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ldif_record() = 21

5
[root@NsfcServer openldap]# ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*
)'
version: 2

#
# filter: (objectclass=*)
# requesting: ALL
#

# search result
search: 2
result: 32 No such object

# numResponses: 1

6 I didn't know whether the ldapadd is succeeded!!
[root@NsfcServer openldap]# ldapadd -x -D "cn=root,dc=example,dc=com" -W -f /hom
e/xdw/testdata.ldif
Enter LDAP Password:
adding new entry "o=Acme,c=US"
ldap_add: No such object

ldif_record() = 32

7 Change slapd.conf
#######################################################################
# ldbm database definitions
#######################################################################

database ldbm
#suffix          "dc=example,dc=com"
#rootdn          "cn=root,dc=example,dc=com"
suffix  "o=Acme,c=US"
rootdn  "cn=root,o=Acme,c=US"
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw  xjtu
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd/tools. Mode 700 recommended.
directory /usr/local/var/openldap-ldbm

8

Kill slapd and restart it!!!


9 I also didn't know whether the ldapadd is succeeded!! I think it successful!!
[root@NsfcServer openldap]# ldapadd -x -D "cn=root,o=Acme,c=US" -W -f /home/xdw/
testdata.ldif
Enter LDAP Password:
adding new entry "o=Acme,c=US"

10 But can't search!!! Why?
[root@NsfcServer openldap]# ldapsearch -x -b 'o=Acme,c=US' '(objectclass=*)'
version: 2

#
# filter: (objectclass=*)
# requesting: ALL
#

# search result
search: 2
result: 0 Success

# numResponses: 1

11 Type a not complete command!!
[root@NsfcServer openldap]# ldapsearch
ldap_sasl_interactive_bind_s: No such object

12 Readd!!
[root@NsfcServer openldap]# ldapadd -x -D "cn=root,o=Acme,c=US" -W -f /home/xdw/
testdata.ldif
Enter LDAP Password:
adding new entry "o=Acme,c=US"
ldap_add: Already exists

ldif_record() = 68

13 Search again!!
[root@NsfcServer openldap]# ldapsearch -x -b 'o=Acme,c=US' 'objectclass=*'
version: 2

#
# filter: objectclass=*
# requesting: ALL
#

# search result
search: 2
result: 0 Success

# numResponses: 1

14 Search again with 'cn=root'
[root@NsfcServer openldap]# ldapsearch -x -b 'cn=root,o=Acme,c=US' 'objectclass=
*'
version: 2

#
# filter: objectclass=*
# requesting: ALL
#

# search result
search: 2
result: 32 No such object
matchedDN: o=Acme,c=US

# numResponses: 1





 

David Hsu
Ph.D
Computer Science
Xi'an Jiaotong University
Xi'an China


MSN Photos is the easiest way to share and print your photos: Click Here