]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/apitest.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / libldap / apitest.c
index e27028a8d6df4e5dc7d08c28072d52c2b5aeb6a2..f2b7d65ddb40d6af2770398c0861ef7234fb5e37 100644 (file)
@@ -1,22 +1,30 @@
-/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/*
- * OpenLDAP API Test
- *     Written by: Kurt Zeilenga
+/* apitest.c -- OpenLDAP API Test Program */
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2013 The OpenLDAP Foundation.
+ * Portions Copyright 1998-2003 Kurt D. Zeilenga.
+ * All rights reserved.
  *
- * This program is designed to test API features of implementations
- * of the IETF draft specifications.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
  *
+ * 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>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This program was orignally developed by Kurt D. Zeilenga for inclusion in
+ * OpenLDAP Software.
  */
 #include "portable.h"
 
+#include <ac/stdlib.h>
+
 #include <stdio.h>
-#include <stdlib.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
 int
 main(int argc, char **argv)
@@ -126,8 +134,8 @@ main(int argc, char **argv)
 #else
                        printf("                     %s\n",
                                api.ldapai_extensions[i]);
-
 #endif
+
                        ldap_memfree(api.ldapai_extensions[i]);
                }
                ldap_memfree(api.ldapai_extensions);
@@ -184,8 +192,50 @@ main(int argc, char **argv)
                printf("  HOST NAME:         %s\n", sval);
                ldap_memfree(sval);
        } else {
-               printf("  HOST NAME:         <not set>\n", sval);
+               puts("  HOST NAME:         <not set>");
        }
 
+#if 0
+       /* API tests */
+       {       /* bindless unbind */
+               LDAP *ld;
+               int rc;
+
+               ld = ldap_init( "localhost", 389 );
+               if( ld == NULL ) {
+                       perror("ldap_init");
+                       return EXIT_FAILURE;
+               }
+
+               rc = ldap_unbind( ld );
+               if( rc != LDAP_SUCCESS ) {
+                       perror("ldap_unbind");
+                       return EXIT_FAILURE;
+               }
+       }
+       {       /* bindless unbind */
+               LDAP *ld;
+               int rc;
+
+               ld = ldap_init( "localhost", 389 );
+               if( ld == NULL ) {
+                       perror("ldap_init");
+                       return EXIT_FAILURE;
+               }
+
+               rc = ldap_abandon_ext( ld, 0, NULL, NULL );
+               if( rc != LDAP_SERVER_DOWN ) {
+                       ldap_perror( ld, "ldap_abandon");
+                       return EXIT_FAILURE;
+               }
+
+               rc = ldap_unbind( ld );
+               if( rc != LDAP_SUCCESS ) {
+                       perror("ldap_unbind");
+                       return EXIT_FAILURE;
+               }
+       }
+#endif
+
        return EXIT_SUCCESS;
 }