Hello all,

I'm a newbie doing LDAP api (Windows SDK) programming. The problem scenario can be explained in the following way.

I have a LDAP client(implemented by me) communicating with LDAP server(Windows 2000 ADS).The goal is to synchronize the data between the LDAP server and LDAP client.

So to synchronize, first the NULL value is BER encoded and OID is set to LDAP_SERVER_DIRSYNC_OID as given in the example

The following is the snippet of the code:
LDAPControl LdapControl;
PLDAPControl LdapControlArray[2];

BerElement *pBerElement = ber_alloc_t(LBER_USE_DER);
if(Result = ber_printf(pBerElement, "{iio}",0,500,NULL,0)
return Result;
if(Result = ber_flatten(pBerElement, pBerValue))
return Result;

ber_free(pBerElement, 1);

LdapControl.ldctl_value.bv_len = pBerValue->bv_len;
LdapControl.ldctl_value.bv_val = pBerValue->bv_val;

LdapControl.ldctl_oid = LDAP_SERVER_DIRSYNC_OID;
LdapControl.ldctl_iscritical = FALSE;

LdapControlArray[0] = &LdapControl;
LdapControlArray[1] = NULL;

if(Result = ldap_search_ext(m_hLdapSessionHandle,
"ObjectClass=*", AttributeList, 0, (PLDAPControl *) &LdapControlArray, NULL, 0, 0, (PULONG)&dwMsgId))
return Result;

If the extended search is issued with this snippet, no results are returned when polled through ldap_result (i.e., only LDAP_RES_SEARCH_RESULT not LDAP_RES_SEARCH_ENTRY).
But if LdapControlArray[0] = NULL; (that is no BER encoding, simple NULL), then whole directory results are returned with the attributes listed in the AttributeList.

How can I get the results? How can I get the server state(say server controls)?

I'll be thankful if anybody can give me hindsight to this.

Thanks in advance

- Jose