Discussion:
Ldapadd or Ldapmodify without ldif file
s***@vanillanetworks.com
2005-11-23 11:12:04 UTC
Permalink
Hello

Is it possible to execute the ldapadd or ldapmodify command without -f
<filename> options where I should pass all contents of file in the
command line. I need this since i wish to process this through some
bash scripts and i don't want scritps to create files in any other
locations.

If it's possible Can somebody say how I can add a new entry using the
following ldif file.

dn: cn=sadique,ou=addressbook,dc=srtachyonldap,dc=com
cn: sadique
displayName: Sadique Puthen Peedikayil
givenName: Sadique
mail: ***@vanillanetworks.com
mobile: 9895643639
homePhone: 0466-2254274
objectClass: inetOrgPerson

Can I pass all these to ldapadd command without using an ldif file?

Thanks
Sadique
Pierangelo Masarati
2005-11-23 16:06:11 UTC
Permalink
Post by s***@vanillanetworks.com
Hello
Is it possible to execute the ldapadd or ldapmodify command without -f
<filename> options where I should pass all contents of file in the
command line.
what about man ldapmodify(1)?

<http://www.openldap.org/software/man.cgi?
query=ldapmodify&apropos=0&sektion=0&manpath=OpenLDAP+2.3-
Release&format=html>

Scroll down right before the "OPTIONS" section.

p.





Ing. Pierangelo Masarati
Responsabile Open Solution

SysNet s.n.c.
Via Dossi, 8 - 27100 Pavia - ITALIA
http://www.sys-net.it
------------------------------------------
Office: +39.02.23998309
Mobile: +39.333.4963172
Email: ***@sys-net.it
------------------------------------------
Buchan Milne
2005-11-23 16:01:00 UTC
Permalink
Post by s***@vanillanetworks.com
Hello
Is it possible to execute the ldapadd or ldapmodify command without -f
<filename> options where I should pass all contents of file in the
command line.
Without -f it reads from stdin. I use it this way and just start typing ...
Post by s***@vanillanetworks.com
I need this since i wish to process this through some
bash scripts and i don't want scritps to create files in any other
locations.
If it's possible Can somebody say how I can add a new entry using the
following ldif file.
Abuse the shell redirection features:

ldapadd ... << EOF
Post by s***@vanillanetworks.com
dn: cn=sadique,ou=addressbook,dc=srtachyonldap,dc=com
cn: sadique
displayName: Sadique Puthen Peedikayil
givenName: Sadique
mobile: 9895643639
homePhone: 0466-2254274
objectClass: inetOrgPerson
EOF

(unquote your own mail of course ...).
--
Buchan Milne
ISP Systems Specialist
B.Eng,RHCE(803004789010797),LPIC-2(LPI000074592)
matthew sporleder
2005-11-23 16:15:18 UTC
Permalink
Yes, I do it all the time.
Just ldapmodify -h myhost -p myport -w mypass -otheroptions

And then you're presented with a blank.
Simply do this:

dn: cn=sadique,ou=addressbook,dc=srtachyonldap,dc=com
changetype: whatever (add, in your case)
rest:
of:
it:

(note blank line)
and it will return just like you had fed it a file.
Check here for ldif help:
http://www.zytrax.com/books/ldap/
Post by s***@vanillanetworks.com
Hello
Is it possible to execute the ldapadd or ldapmodify command without -f
<filename> options where I should pass all contents of file in the
command line. I need this since i wish to process this through some
bash scripts and i don't want scritps to create files in any other
locations.
If it's possible Can somebody say how I can add a new entry using the
following ldif file.
dn: cn=sadique,ou=addressbook,dc=srtachyonldap,dc=com
cn: sadique
displayName: Sadique Puthen Peedikayil
givenName: Sadique
mobile: 9895643639
homePhone: 0466-2254274
objectClass: inetOrgPerson
Can I pass all these to ldapadd command without using an ldif file?
Thanks
Sadique
Karsten Gorling
2005-11-23 16:16:52 UTC
Permalink
Post by s***@vanillanetworks.com
Can I pass all these to ldapadd command without using an ldif file?
As it is written in the manpage, ldapadd uses either STDIN or the file
given by the value of the -f parameter. So you can hang ldapadd just at
the end of a pipe.
--
Max-Born-Institut (MBI)/Max-Born-Straße 2A/12489 Berlin/Karsten Gorling
Telefon: ++49 30 6392 1341 / Telefax: ++49 30 6392 1309
E-Mail: ***@physik.tu-berlin.de or ***@mbi-berlin.de
Instantmessenger: Jabber: ***@jabber.fsinf.de or ICQ: 95492828
PGP-Fingerprint: 4BEF 23EA 02AE BACA 9918 31FF 285B 0426 0E1A B2FC
----------------- > encrypted E-Mail preferred <------------------------
Loading...