Search code examples
shellldapldif

ldapadd/modify a single entry


I want to add a new entry to my LDAP server without using an .ldif file. the reasons for this is I am connecting to the server remotely and the file wont be present. The command to add entries from a file is:

$ ldapmodify -h hostName -p 10389 -D "uid=admin,ou=system" -w ****** -a -f e.ldif

how can I change the above to add this user without using .ldif file:

dn: cn=Person Name 7,dc=example,dc=com
objectclass: top
objectclass: inetOrgPerson
objectclass: person
objectclass: organizationalPerson
cn: Person Name 7
sn: Person 7
description: Sir Thomas Masterman Hardy
givenname: Person
homePhone: 11119211
mail: person7@royal.co.uk
telephoneNumber: 11111
uid: person7

I have looked online but all the examples seem to show file only. Is this possible?


Solution

  • According to the man page, the default behavior of ldapmodify is actually not to use a file but rather to take its information from stdin -- i.e. from someone typing it in. By using -f on the command line you're actually circumventing that normal behavior. Try doing:

    ldapmodify -h hostName -p 10389 -D "uid=admin,ou=system" -w ***** -a
    

    and then paste or type in the information. (You may have to type CtrlD when you're done typing in the information in order to tell ldapmodify that you're done.)