1 #define LDAP_DEPRECATED 1 6 int main(
int argc,
const char *argv[])
10 #define HOSTNAME "localhost" 11 #define PORT_NUMBER LDAP_PORT 12 #define FIND_DN "uid=bjensen, ou=People, dc=example,dc=com" 18 const string host =
"161.72.93.133";
21 LDAPMessage *result, *e;
27 if (!(ld = ldap_init(host.c_str(), LDAP_PORT)))
29 perror(
"ldap_init" );
50 rc = ldap_simple_bind_s( ld, NULL, NULL );
51 if ( rc != LDAP_SUCCESS )
53 fprintf(stderr,
"ldap_simple_bind_s: %s\n", ldap_err2string(rc));
57 if ( ( rc = ldap_search_ext_s( ld,
"ou=People,dc=fact,dc=iac,dc=es", LDAP_SCOPE_BASE,
58 "(objectclass=*)", NULL, 0, NULL, NULL, LDAP_NO_LIMIT,
59 LDAP_NO_LIMIT, &result ) ) != LDAP_SUCCESS )
61 fprintf(stderr,
"ldap_search_ext_s: %s\n", ldap_err2string(rc));
67 e = ldap_first_entry( ld, result );
70 printf(
"\nFound %s:\n\n",
FIND_DN );
72 for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL; a = ldap_next_attribute( ld, e, ber ) )
75 if ((vals = ldap_get_values( ld, e, a)) != NULL )
77 for ( i = 0; vals[
i] != NULL; i++ ) {
78 printf(
"%s: %s\n", a, vals[i] );
80 ldap_value_free( vals );
88 ldap_msgfree( result );
int main(int argc, const char *argv[])