18,356
社区成员
发帖
与我相关
我的任务
分享
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 );
}