window 2003 ldap api的问题,求解答

rocsoar 2013-08-26 12:23:09
操作系统:windows 2003 server
场景:一个定时程序,连接windows ad server同步数据
错误:运行一段时间后,api 函数ldap_get_next_page_s返回local_error错误,此时循环会结束,等待下一次定时,但从这以后的每一次的定时执行ldap_get_next_page_s总会返回local_other错误,除非重启进程
一下是部分代码:

unsigned long ulErrorCode = LDAP_SUCCESS;
LDAPMessage* pLDAPMessage = NULL;
PLDAPSearch pSearch = NULL;
pSearch = ldap_search_init_page(this->GetLADPHandle(),pszBaseDN,ulScope,
pszFilter,pszAttribs,0,NULL,NULL,this->GetTimeOut(),0,NULL);
if (pSearch == NULL)
{
this->SetLastError(::LdapGetLastError());

this->SetLastFuncName("ldap_search_init_page");

return false;

}
unsigned long ulTotalCount = 0;
l_timeval* pTimeOut = NULL;
l_timeval tTimeOut;
tTimeOut.tv_sec = this->GetTimeOut();
tTimeOut.tv_usec = 0;
if (this->GetTimeOut() > 0)
{
pTimeOut = &tTimeOut;
}
while(ulErrorCode == LDAP_SUCCESS)
{

ulErrorCode = ldap_get_next_page_s(this->GetLADPHandle(),pSearch,pTimeOut,this->GetPageSize(),&ulTotalCount,&pLDAPMessage);

if(ulErrorCode == LDAP_SUCCESS)

{

if(!this->ProcessSearchMessage(pLDAPMessage,vecLDAPEntryList,pLDAPEntryParent))
{
if(pLDAPMessage != NULL)
{
ldap_msgfree(pLDAPMessage);
pLDAPMessage = NULL;
}
ldap_search_abandon_page(this->GetLADPHandle(), pSearch);
//pSearch = NULL;
return false;
}
}
if(pLDAPMessage != NULL)
{
ldap_msgfree(pLDAPMessage);
pLDAPMessage = NULL;
}
}
ldap_search_abandon_page(this->GetLADPHandle(), pSearch);
//pSearch = NULL;
if(ulErrorCode != LDAP_NO_RESULTS_RETURNED)
{
this->SetLastError(ulErrorCode);
this->SetLastFuncName("ldap_get_next_page_s");
return false;
}
}

困扰很久了,就解答
...全文
169 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qishine 版主 2013-08-27
  • 打赏
  • 举报
回复
代码不懂.代码不懂.
rocsoar 2013-08-26
  • 打赏
  • 举报
回复
没人吗?急啊

6,849

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧