Testing the LDAP configuration
Previous  Top  Next

To finally add the entry to the ldap database, we will use a programm called ldapadd by typing

ldapadd –D "cn=Manager,o=Organic Brown Suger,c=US" –W –f /tmp/root.ldif

When asked for a password, please enter secret. This should produce an output similar to:

adding new entry o=Organic Brown Sugar, c=US

If your output matches and you didn't get any error messages, verify it with the ldapsearch commando like this:

ldapsearch –u –b '' –s sub '(objectclass=*)'

This should display the one or two entries you created for the root of the hirarchy. To make things a little more fun we will add another entry that has a telephonenumber and an email address. Create a file /tmp/entry1.ldif and enter the following data:

dn: cn=Buffalo Bill,o=Organic Brown Sugar,c=US
objectclass: person
cn: Buffalo Bill
cn: Bill Buffalo
sn: Buffalo
mail: buffalo.bill@organicbrownsugar.com
mail: buffalo.bill@animalhunting.com
telephonenumber: +001 (987) 654-3210

Note here that you can have multiple attributes defined, cn and mail show up twice here. Make sure you separate multiple entries with a blank line. dn stands for distinguished name and should be unique for every entry. I could have also used dn: cn=Buffalo Bill, dc=organicbrownsugar,dc=com instead in the first line, or a combination. Now type

ldapadd –D "cn=Manager,o=Organic Brown Suger,c=US" –W –f /tmp/entry1.ldif

and if you don't see any errors, type immediately:
ldapsearch –u –b '' –s sub '(objectclass=*)'
Do you see Buffalo Bill? If yes, we both have succeeded. Now delete the entry by typing:

ldapdelete –D "cn=Manager,o=Organic Brown Suger,c=US" "cn=Buffalo Bill,o=Organic Brown Sugar, c=US" –W

One last word on ldap. Befory you start adding entries to an organizational unit, make sure you create the organizational unit itself first with the objectclass=organizationalUnit objectclass.


Congratulations! Stand up, have your favorite drink and call your computer friends to tell them that you escaped the
magic powers of Bill Gates and is supporters
J