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

Re: CLDAP request - Netlogon attribute


I finally managed to write code which can sent the CLDAP request using openldap apis for Netlogon attribute. But for some reason the CLDAP response contains zero results. There is no search entry but only search result is returned in the CLDAP response.

I would appreciate if anyone can help me to know the reason for not getting the response with netlogon attribute values.

Thanks in Advance,

Below is my code...

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

#define LDAP_HOSTNAME    "xxxhost.domain.local"
#define LDAP_PORT    389

int find_netlogon( LDAP *ld, LDAPMessage **res, char *domain, char *host, char *attr ) { char *Attr[] = { attr, NULL }; char search_exp[1024];

   sprintf (search_exp, "(&(DnsDomain=%s)(Host=%s)(Ntver=\006))", domain, host);
   return ldap_search_s (ld, NULL, LDAP_SCOPE_BASE,
                       search_exp, Attr, 0, res);


int main(int argc, char *argv[])
LDAPURLDesc url;
char *ldapuri = NULL;
LDAP *ld = NULL;
int rc;
int ldap_debug = 127; /*LDAP_DEBUG_TRACE */ LDAPMessage *res;

   memset( &url, 0, sizeof(url));
   url.lud_scheme = "cldap";
   url.lud_host = LDAP_HOSTNAME;
   url.lud_port = LDAP_PORT;
   url.lud_scope = LDAP_SCOPE_BASE;

   (void) ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldap_debug);

ldapuri = ldap_url_desc2str( &url );

   rc = ldap_initialize( &ld, ldapuri );

if( rc != LDAP_SUCCESS ) { fprintf( stderr, "ldap_initialize( %s ) failed with error (%d): %s\n",
ldapuri != NULL ? ldapuri : "<DEFAULT>", rc, ldap_err2string(rc) ); }else
printf("LDAP initialize successful\n");

(void)ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &rc);
(void)ldap_set_option(ld, LDAP_OPT_REFERRALS , 0);

rc = ldap_bind_s( ld, "", "", LDAP_AUTH_SIMPLE );
if (rc != LDAP_SUCCESS) {
ldap_perror(ld, "ldap_simple_bind"); printf("Error occured while ldap_simple_bind\n");
goto clean_exit;
printf("ldap_simple_bind_s successful.\n");

printf("calling find_netlogon...\n");
rc = find_netlogon(ld, &res, "domain.local", "xxxhost", "Netlogon");
if (rc != LDAP_SUCCESS) { printf("Error occured while find_netlogon\n");
goto clean_exit;
} else if (rc == LDAP_SUCCESS && ldap_count_entries(ld, res) == 0)
printf("No records found\n");
printf("No of records found: %d\n", ldap_count_entries(ld, res));

if(ld) ldap_unbind(ld);