I'm not sure that changing the filter to (objectClass=*) will work. In my
idea it will make a infinite loop.
If you don't have only organizationalUnit as structural class in your DIT,
i think that a filter on the exhaustive list of your structural class is
better. ex:(|(objectClass=organizationalUnit)(
objectClass=anotherStructuralClass))...

Yves-Marie LAINE



                                                                                       
                           
                                                                                       
                           
                                         Pour :  Brian Reichert <[EMAIL PROTECTED]>    
                        
                                         cc :    [EMAIL PROTECTED]                     
                          
                                         Objet :      Re: technique for recursive 
delete?                         
                                                                                       
                           
          15/08/2004 03:15  Peter                                                      
                           
          Lavender                                                                     
                           
          <[EMAIL PROTECTED]>                                                          
                       
                    Veuillez                                                           
                           
                    r�pondre �                                                         
                           
                    plaven                                                             
                           
                                                                                       
                           
                                                                                       
                           





>Thanks for all the feedback.  I went ahead an wrote a simple recursive
>desent for my containers.  I made the assumption that they were all
>organizationalUnits.
>
>

But what if the OU is not the only way you have structured your DIT?

By changing the filter to objectClass=* it will remove your current
assumption that each "container" object is an OU.  This means you should
be able to simply have  a startpoint to pass your sub routine and let it
rip.  :)

So if you have a (contrived) DIT that for example has

ou=sales,ou=factory1,l=location3,l=location2,o=big Org,c=uk

and you wanted to delete all entries under l=location2, your subroutine
doesn't have to change.

Just a thought..

>I'm not going to claim this will work for everyone, but this works
>for me:
>
>#--------
># recursively delete a container.
>
>sub container_descend
>{
>  my $base = shift;
>  my $ldap = shift;
>
>  my $mesg = $ldap->search( base => $base, scope=> 'one',
>            filter => 'objectclass=organizationalUnit',
>  );
>
>  foreach my $entry ($mesg->all_entries)
>  { &container_descend($entry->dn, $ldap); }
>
>  $mesg = $ldap->search( base => $base, scope=> 'one',
>            filter => 'objectclass=*',
>  );
>
>  foreach my $entry ($mesg->all_entries)
>  {
>    my $result = $ldap->delete($entry);
>    if (defined $result) { $result->code && warn "failed: ",
$result->error ; }
>  }
>
>  $debug && print $tag."- deleting $base\n";
>  my $result = $ldap->delete($base);
>  if (defined $result) { $result->code && warn "failed: ", $result->error
; }
>}
>
>
 >




*****************************************************************************
Tout usage de ce message par une personne autre que son destinataire
est strictement interdit. L'integrite de ce message n'etant pas assuree
sur Internet, Le groupement des Mousquetaires ne peut etre tenu responsable
de son contenu.
Toute utilisation ou diffusion non autorisee est interdite. Si vous
n'etes pas destinataire de ce message, merci de le detruire et d'avertir
l'expediteur
***************************************************************************** 

Reply via email to