5. Testing the LDAP directory

5.1. Performing a search

To perform a search and find all entries just do the following LDAP query:


	ldapsearch -b "o=sql,c=RU" "(objectClass=*)"

This must return some result else you have miss something during the previous chapter.

To test more the SQL backend you can run the following test suite. All test are done in LDIFF format.

Something great is that you can create flat LDAP structure like in this test or more complex structure as tree.

5.2. Creating entry

To create some new entries just copy the following LDIFF code into a file and run the following command:

	ldapadd -D "cn=root,o=sql,c=RU" -w secret -f file
Note that it assume that your LDAP server is on localhost.


	# begin

	dn: cn=User Test_Add_Entry,o=sql,c=RU
	objectClass: inetOrgPerson
	sn: First Test_Add_Entry user
	cn: User Test_Add_Entry

	# end

5.3. Setting entry attribute

To set attributes of the new entries just copy the following LDIFF code into a file and run command:

	ldapmodify -D "cn=root,o=sql,c=RU" -w secret -f file
Note that it assume that your LDAP server is on localhost.



	# begin

	dn: cn=User Test_Add_Entry,o=sql,c=RU
	changetype: modify
	replace: sn
	sn: Test_Add_Entry user

	dn: cn=User Test_Add_Entry,o=sql,c=RU
	changetype: modify
	add: telephoneNumber
	telephoneNumber: 123-4567
	telephoneNumber: 765-4321

	# end

5.4. Performing a search

To perform a search and find all entries just do the following LDAP query:


	ldapsearch -b "o=sql,c=RU" "(objectClass=*)"

or just under the inetOrgPerson objectClass with cn begining with letter M:


	ldapsearch -b "o=sql,c=RU" "(&(objectClass=inetOrgPerson) (cn=M*))"

5.5. Deleting attribute

To delete attributes of the new entries just copy the following LDIFF code into a file and run command:

	ldapmodify -D "cn=root,o=sql,c=RU" -w secret -f file
This is an example with deleting an attribute with multiple values.


	# begin

	dn: cn=User Test_Add_Entry,o=sql,c=RU
	changetype: modify
	delete: telephoneNumber
	telephoneNumber: 332-2334

	# end

5.6. Deleting entry

To delete entry just copy the following LDIFF code into a file and run command:

	ldapadd -f file
Note that it assume that your LDAP server is on localhost.


	# begin

	dn: cn=User Test_Add_Entry,o=sql,c=RU
	changetype: delete

	# end