win32的 ldap api拉取服务器端的用户列表的问题

hurryboylqs 2015-04-14 04:25:56
想 实现读取服务器端的用户列表,但是ldap_search_s就返回操作错误了,不知道是那个参数没搞对还是,有熟悉LDAP的吗

LDAP *ld;
LDAPMessage *res=NULL, *e=NULL;
int i;
char *a, *dn;
void *ptr;
char **vals;

/* open a connection */
ld = ldap_init(_T("192.168.19.11"), LDAP_PORT );

/* authenticate as nobody */
if ( ldap_simple_bind_s( ld, NULL,NULL) != LDAP_SUCCESS )
{
exit( 1 );
}

/* search for entries with cn of "Babs Jensen",
return all attrs */

PTCHAR searchFilter = _T("(&(objectClass=user)(name=*))");
PTCHAR returnedAtts[2];
returnedAtts[0]= _T("memberOf");
returnedAtts[1]= NULL;

if ( ldap_search_s( ld,_T("dc=rich001,dc=com"),
LDAP_SCOPE_SUBTREE, NULL, NULL, 0, &res )
!= LDAP_SUCCESS )
{
//ldap_search_s这里返回错误了
ULONG uError =LdapGetLastError();
TCHAR* pError = ldap_err2string(uError);//错误解析是: 操作错误
exit( 1 );
}


想实现这里的功能一样 但他是java的 我需要C++的
http://www.tuicool.com/articles/bqimIn
...全文
163 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hurryboylqs 2015-04-21
  • 打赏
  • 举报
回复
用ADSI接口搞定了,http://blog.csdn.net/hurryboylqs/article/details/45170331
hurryboylqs 2015-04-17
  • 打赏
  • 举报
回复
没人做过?

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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