]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapdelete.c
Don't assume response control is a paged results response.
[openldap] / clients / tools / ldapdelete.c
index 74402e999078137386562b36fc2952fe9a42ad21..27d199b13fd9125907c196d99ec7035b13f94f1a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2006 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
@@ -39,6 +39,7 @@
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/unistd.h>
+#include <ac/time.h>
 
 #include <ldap.h>
 #include "lutil.h"
@@ -169,7 +170,7 @@ main( int argc, char **argv )
 
        tool_bind( ld );
 
-       if ( assertion || authzid || manageDSAit || noop ) {
+       if ( assertion || authzid || manageDIT || manageDSAit || noop ) {
                tool_server_controls( ld, NULL, 0 );
        }
 
@@ -197,9 +198,9 @@ main( int argc, char **argv )
                }
        }
 
-       ldap_unbind_ext( ld, NULL, NULL );
-
-    return( retval );
+       tool_unbind( ld );
+       tool_destroy();
+    return retval;
 }
 
 
@@ -233,10 +234,25 @@ static int dodelete(
                return rc;
        }
 
-       rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, NULL, &res );
-       if ( rc < 0 ) {
-               ldap_perror( ld, "ldapdelete: ldap_result" );
-               return rc;
+       for ( ; ; ) {
+               struct timeval tv;
+
+               if ( tool_check_abandon( ld, id ) ) {
+                       return LDAP_CANCELLED;
+               }
+
+               tv.tv_sec = 0;
+               tv.tv_usec = 100000;
+
+               rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
+               if ( rc < 0 ) {
+                       ldap_perror( ld, "ldapdelete: ldap_result" );
+                       return rc;
+               }
+
+               if ( rc != 0 ) {
+                       break;
+               }
        }
 
        rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );
@@ -250,7 +266,8 @@ static int dodelete(
        if( verbose || code != LDAP_SUCCESS ||
                (matcheddn && *matcheddn) || (text && *text) || (refs && *refs) )
        {
-               printf( _("Delete Result: %s (%d)\n"), ldap_err2string( code ), code );
+               printf( _("Delete Result: %s (%d)\n"),
+                       ldap_err2string( code ), code );
 
                if( text && *text ) {
                        printf( _("Additional info: %s\n"), text );