1998-11-05 10:48:41 +08:00
|
|
|
/*
|
|
|
|
* OpenLDAP API Test
|
|
|
|
* Written by: Kurt Zeilenga
|
|
|
|
*
|
|
|
|
* This program is designed to test libldap API for conformance
|
|
|
|
* to draft-api-ldapext-ldap-c-api-01.txt.
|
|
|
|
*/
|
1998-11-05 04:09:07 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
1998-11-11 13:50:51 +08:00
|
|
|
#include <stdlib.h>
|
1998-11-05 04:09:07 +08:00
|
|
|
#include <ac/time.h>
|
|
|
|
|
|
|
|
#include "lber.h"
|
|
|
|
#include "ldap.h"
|
|
|
|
|
1998-11-11 04:27:47 +08:00
|
|
|
int
|
1998-11-05 04:09:07 +08:00
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
LDAPAPIInfo api;
|
|
|
|
int ival;
|
1998-11-11 04:27:47 +08:00
|
|
|
char *sval;
|
1998-11-05 04:09:07 +08:00
|
|
|
|
|
|
|
#ifdef LDAP_API_INFO_VERSION
|
|
|
|
api.ldapai_info_version = LDAP_API_INFO_VERSION;
|
|
|
|
#else
|
|
|
|
api.ldapai_info_version = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
printf("Compile time API Information\n");
|
|
|
|
printf(" API Info version: %d\n", api.ldapai_info_version);
|
|
|
|
printf(" API version: %d\n", LDAP_API_VERSION);
|
|
|
|
#ifdef LDAP_VERSION
|
|
|
|
printf(" Protocol Version: %d\n", LDAP_VERSION);
|
|
|
|
#else
|
|
|
|
printf(" Protocol Version: unknown\n");
|
|
|
|
#endif
|
|
|
|
#ifdef LDAP_VERSION_MIN
|
|
|
|
printf(" Protocol Min: %d\n", LDAP_VERSION_MIN);
|
|
|
|
#else
|
|
|
|
printf(" Protocol Min: unknown\n");
|
|
|
|
#endif
|
|
|
|
#ifdef LDAP_VERSION_MAX
|
|
|
|
printf(" Protocol Max: %d\n", LDAP_VERSION_MAX);
|
|
|
|
#else
|
|
|
|
printf(" Protocol Max: unknown\n");
|
|
|
|
#endif
|
|
|
|
#ifdef LDAP_VENDOR_NAME
|
|
|
|
printf(" Vendor Name: %s\n", LDAP_VENDOR_NAME);
|
|
|
|
#else
|
|
|
|
printf(" Vendor Name: unknown\n");
|
|
|
|
#endif
|
|
|
|
#ifdef LDAP_VENDOR_VERSION
|
|
|
|
printf(" Vendor Version: %d\n", LDAP_VENDOR_VERSION);
|
|
|
|
#else
|
|
|
|
printf(" Vendor Version: unknown\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) != LDAP_SUCCESS) {
|
1998-11-11 04:27:47 +08:00
|
|
|
fprintf(stderr, "%s: ldap_get_option(api) failed\n", argv[0]);
|
1998-11-05 04:09:07 +08:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nExecution time API Information\n");
|
|
|
|
printf(" API Info version: %d\n", api.ldapai_info_version);
|
|
|
|
|
|
|
|
if (api.ldapai_info_version != LDAP_API_INFO_VERSION) {
|
1998-11-11 04:27:47 +08:00
|
|
|
printf(" API INFO version mismatch!\n");
|
1998-11-05 04:09:07 +08:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" API Version: %d\n", api.ldapai_api_version);
|
|
|
|
printf(" Protocol Max: %d\n", api.ldapai_protocol_version);
|
1998-11-05 14:16:11 +08:00
|
|
|
|
1998-11-05 04:09:07 +08:00
|
|
|
if(api.ldapai_extensions == NULL) {
|
|
|
|
printf(" Extensions: none\n");
|
1998-11-05 14:16:11 +08:00
|
|
|
|
1998-11-05 04:09:07 +08:00
|
|
|
} else {
|
|
|
|
int i;
|
1998-11-11 04:27:47 +08:00
|
|
|
for(i=0; api.ldapai_extensions[i] != NULL; i++) /* empty */;
|
|
|
|
printf(" Extensions: %d\n", i);
|
1998-11-05 04:09:07 +08:00
|
|
|
for(i=0; api.ldapai_extensions[i] != NULL; i++) {
|
|
|
|
printf(" %s\n",
|
|
|
|
api.ldapai_extensions[i]);
|
|
|
|
}
|
|
|
|
}
|
1998-11-05 14:16:11 +08:00
|
|
|
|
1998-11-05 04:09:07 +08:00
|
|
|
printf(" Vendor Name: %s\n", api.ldapai_vendor_name);
|
|
|
|
printf(" Vendor Version: %d\n", api.ldapai_vendor_version);
|
|
|
|
|
|
|
|
printf("\nExecution time Default Options\n");
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_DEREF, &ival) != LDAP_SUCCESS) {
|
1998-11-11 04:27:47 +08:00
|
|
|
fprintf(stderr, "%s: ldap_get_option(api) failed\n", argv[0]);
|
1998-11-05 04:09:07 +08:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" DEREF: %d\n", ival);
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_SIZELIMIT, &ival) != LDAP_SUCCESS) {
|
1998-11-11 04:27:47 +08:00
|
|
|
fprintf(stderr, "%s: ldap_get_option(sizelimit) failed\n", argv[0]);
|
1998-11-05 04:09:07 +08:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" SIZELIMIT: %d\n", ival);
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_TIMELIMIT, &ival) != LDAP_SUCCESS) {
|
1998-11-11 04:27:47 +08:00
|
|
|
fprintf(stderr, "%s: ldap_get_option(timelimit) failed\n", argv[0]);
|
1998-11-05 04:09:07 +08:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" TIMELIMIT: %d\n", ival);
|
1998-11-05 14:18:06 +08:00
|
|
|
|
1998-11-11 04:27:47 +08:00
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_REFERRALS, &ival) != LDAP_SUCCESS) {
|
|
|
|
fprintf(stderr, "%s: ldap_get_option(referrals) failed\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" REFERRALS: %s\n",
|
|
|
|
ival == (int) LDAP_OPT_ON ? "on" : "off");
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_RESTART, &ival) != LDAP_SUCCESS) {
|
|
|
|
fprintf(stderr, "%s: ldap_get_option(restart) failed\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" RESTART: %s\n",
|
|
|
|
ival == (int) LDAP_OPT_ON ? "on" : "off");
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ival) != LDAP_SUCCESS) {
|
|
|
|
fprintf(stderr, "%s: ldap_get_option(protocol version) failed\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" PROTOCOL VERSION: %d\n", ival);
|
|
|
|
|
|
|
|
if(ldap_get_option(NULL, LDAP_OPT_HOST_NAME, &sval) != LDAP_SUCCESS) {
|
|
|
|
fprintf(stderr, "%s: ldap_get_option(host name) failed\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
printf(" HOST NAME: %s\n", sval);
|
|
|
|
|
1998-11-05 14:18:06 +08:00
|
|
|
exit(0);
|
1998-11-11 04:27:47 +08:00
|
|
|
return 0;
|
1998-11-05 04:09:07 +08:00
|
|
|
}
|