[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
problem with ldap_search _ext and ldap_result
- To: openldap-technical@openldap.org
- Subject: problem with ldap_search _ext and ldap_result
- From: siva prakash <rheosiva@gmail.com>
- Date: Thu, 16 Dec 2010 19:39:19 +0530
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=t2wrp1+2E2QbMd6p6mLWv5DJxuE4wcTek+BesVNimPM=; b=U9a+TJ3CTG0bpE4vexzxMYA0CD6aRLT0bhabgjasNggn+Ggn+2MgCY3WDsuY4wRw8G FHOTGZcXt8aooDbwKqJExWBSD/i0ZCxun64Ul1DyaGHorewde+qia/iKB9X77uyKV9Ai ILkLxW+oDSQVCcH7y3oLD3EgK/42yqBP31v4w=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=qK/AVx04cFl5/1Bi0HOmgnSCP6LDzv5k9xNo5KDQkcMoevymuOqKdsD3Is7ELwEZvv niWN2qkfDeTngoNUhl+cSpcijfORWgO1wZ8XM38meOCIDkNuazSkCIabQ/qr6VkGdxUA VPfkj9vruS1bJPxBJDR/3BcXSJNHoHNqQKWdU=
After binding the ldap server, here are my code snippets,
finished = 0;
rc = ldap_search_ext( ld, "
testactivedirectory.com", sub_tree, "(sAMAccountName=user1)", NULL, 0, NULL, NULL, NULL, 1, &msgid );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_search_ext: %s \n", ldap_err2string( rc ) );
ldap_unbind( ld );
return( 1 );
}
while (!finished)
{
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &res );
printf("check the search result :%d\n", rc);
switch ( rc ) {
case -1:
fprintf( stderr, "ldap_result: %s\n", ldap_err2string( rc ) );
ldap_unbind( ld );
return( 1 );
case 0:
break;
case LDAP_RES_SEARCH_ENTRY:
/* Get and print the DN of the entry. */
if (( dn = ldap_get_dn( ld, res )) != NULL ) {
printf( "dn-> %s\n", dn );
ldap_memfree( dn );
}
break;
case LDAP_RES_SEARCH_RESULT:
finished = 1;
break;
default:
break;
}
}
while running this program, i could get the intended result what the distinguished name i want, but the ldap_result in not being exit with LDAP_RES_SEARCH_RESULT option. it tooks lot of time to respond with LDAP_RES_SEARCH_RESULT, even no more entry to provide.
check the search result :100
dn-> CN=user1,CN=Users,DC=testactivedirectory,DC=com
(it waits in looop... it exits after a very long time)
check the search result :101
i wanted to avoid this waiting time, even i have been sending entries should be limited to 1, it doesn't seems to be reflected,
i have found other way of fixing this, doing two bind and two unbind option. but that is not seems a optimized manner.
Let me know how to fix this problem,
Thanks,
LDAP Learner