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

Re: Discussion: ldapdelete.c

On Thu, 04 Mar 1999 15:00:23 EST, Ben Collins wrote:
> On Thu, Mar 04, 1999 at 11:51:50AM -0800, JR Heisey wrote:
> > I think it would be a convienence if ldapdelete could
> > read an LDIF file ingorning all lines except the line
> > the begin with 'DN: '. Then delete entry specified by
> > the DN field.
> Simple solution:
> grep ^dn: temp.ldif | awk -F: '{ print $2; }' | ldapdelete
> > Generate an LDIF list using a filer (i.e.
> > objectclass=person)
> > then use ldapdelete to remove all the entries returned.
> Easy as well:
> ldapsearch objectclass=person dn | ldapdelete

I think that would only work by accident. You're asking for all entries 
matching (objectclass=person), and selecting an attribute called 'dn' 
from each one. This would print:

cn=Foo, dc=example, dc=com

cn=Bar, dc=example, dc=com

but only if the entries didn't have an attribute named 'dn', and 'dn' 
was a known attribute type. If they did exist, you'd get:

cn=Foo, dc=example, dc=com
dn= cn=Foo Bar,o=example,c=US

cn=Bar, dc=example, dc=com
dn= cn=Bar Foo,o=example,c=US

or something, which is not valid input for ldapdelete, I think.

Your awk script will go awry if any of the DNs contains colons as well