[Date Prev][Date Next] [Chronological] [Thread] [Top]

Error to get LDAP_OPT_API_INFO


I'm trying to get the version with a small C program, 
however ldap_get_options always returns an error, I'm
still can't see where is the problem. I can get other
options, such as, LDAP_OPT_HOST_NAME, but not the version.

I made an small test program, quite simple.  I'll appreaciate
any hint.

My server:
ii  slapd          2.0.27-3       OpenLDAP server (slapd).

In a Debian sid machine.  I tryed to ask to others OpenLDAP
servers without success.

I tryied the following:

$ gcc -o ldap-test -Wall -lldap ldap-test.c
$ ./ldap-test localhost
success: localhost:389

The source code:

#include <stdio.h>
#include <stdlib.h>
#include <ldap.h>

main (int argc, char **argv)
	LDAP *ldap;
	LDAPAPIInfo ldapinfo;
	char *hostname;
	int result;

	if (argc < 2) {
		printf ("Usage: %s <hostname>\n", argv[0]);
		return -1;
	ldap = ldap_init (argv[1], 389);

	if (ldap_bind_s (ldap, NULL, NULL, LDAP_AUTH_SIMPLE) !=
		printf ("ldap_bind_s: error\n");
		return -1;

	result = ldap_get_option (ldap, LDAP_OPT_API_INFO, &ldapinfo);
	if (result == LDAP_OPT_SUCCESS) {
		printf ("success: %s\n", ldapinfo.ldapai_vendor_name);
	} else {
		printf ("failure\n");

	result = ldap_get_option (ldap, LDAP_OPT_HOST_NAME, &hostname);
	if (result == LDAP_OPT_SUCCESS) {
		printf ("success: %s\n", hostname);
	} else {
		printf ("failure\n");
	free (hostname);

	return 0;

Thanks in advance,

German Poo Caaman~o
"Hay 10 tipos de personas: las que entienden binario y las que no."