]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapmodrdn.c
drop stored procedures
[openldap] / clients / tools / ldapmodrdn.c
index 53db82726d730af4d525af2a78ebf12708da64bb..33c4b2934e3cfcbaf2d257c73f429799b165ca50 100644 (file)
@@ -1,22 +1,48 @@
+/* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP.
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Portions Copyright 1998-2003 Kurt D. Zeilenga.
+ * Portions Copyright 1998-2001 Net Boolean Incorporated.
+ * Portions Copyright 2001-2003 IBM Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
  *
- * Support for MODIFYDN REQUEST V3 (newSuperior) by:
- * 
- * Copyright 1999, Juan C. Gomez, All rights reserved.
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* Portions Copyright 1999, Juan C. Gomez, All rights reserved.
  * This software is not subject to any license of Silicon Graphics 
  * Inc. or Purdue University.
  *
  * Redistribution and use in source and binary forms are permitted
  * without restriction or fee of any kind as long as this notice
  * is preserved.
+ */
+/* Portions Copyright (c) 1992-1996 Regents of the University of Michigan.
+ * All rights reserved.
  *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.  This
+ * software is provided ``as is'' without express or implied warranty.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).  Additional significant contributors
+ * include:
+ *    Kurt D. Zeilenga
+ *    Juan C Gomez
  */
 
+
 #include "portable.h"
 
 #include <stdio.h>
@@ -26,6 +52,7 @@
 #include <ac/ctype.h>
 #include <ac/string.h>
 #include <ac/unistd.h>
+#include <ac/time.h>
 
 #include <ldap.h>
 #include "lutil.h"
@@ -63,7 +90,7 @@ usage( void )
 
 
 const char options[] = "rs:"
-       "cCd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
+       "cd:D:e:f:h:H:IkKMnO:p:P:QR:U:vVw:WxX:y:Y:Z";
 
 int
 handle_private_option( int i )
@@ -72,7 +99,7 @@ handle_private_option( int i )
 #if 0
                int crit;
                char *control, *cvalue;
-       case 'E': /* modrdn controls */
+       case 'E': /* modrdn extensions */
                if( protocol == LDAP_VERSION2 ) {
                        fprintf( stderr, _("%s: -E incompatible with LDAPv%d\n"),
                                prog, version );
@@ -94,7 +121,7 @@ handle_private_option( int i )
                if ( (cvalue = strchr( control, '=' )) != NULL ) {
                        *cvalue++ = '\0';
                }
-               fprintf( stderr, _("Invalid modrdn control name: %s\n"), control );
+               fprintf( stderr, _("Invalid modrdn extension name: %s\n"), control );
                usage();
 #endif
 
@@ -171,8 +198,9 @@ main(int argc, char **argv)
 
        tool_bind( ld );
 
-       if ( authzid || manageDSAit || noop )
+       if ( assertion || authzid || manageDSAit || noop ) {
                tool_server_controls( ld, NULL, 0 );
+       }
 
     retval = rc = 0;
     if (havedn)
@@ -200,8 +228,8 @@ main(int argc, char **argv)
        }
     }
 
-    ldap_unbind( ld );
-
+       tool_unbind( ld );
+       tool_destroy();
     return( retval );
 }
 
@@ -236,10 +264,25 @@ static int domodrdn(
                return rc;
        }
 
-       rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, NULL, &res );
-       if ( rc < 0 ) {
-               ldap_perror( ld, "ldapmodrdn: ldap_result" );
-               return rc;
+       for ( ; ; ) {
+               struct timeval  tv = { 0 };
+
+               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, "ldapmodrdn: ldap_result" );
+                       return rc;
+               }
+
+               if ( rc != 0 ) {
+                       break;
+               }
        }
 
        rc = ldap_parse_result( ld, res, &code, &matcheddn, &text, &refs, NULL, 1 );