主机服务器上的 Ldap 搜索

Ldap Search on the host server

我开发了一个小型 C++ 应用程序来绑定服务器中的用户,使用 active directory 然后 return 他的组名。 问题是当我 运行 来自远程计算机的应用程序时,它 运行 没有问题。当我尝试在主机服务器上 运行 它时,-托管 active directory 的计算机- 绑定过程通过,但搜索功能总是 return Operation error:这是一个我的代码示例。

 if ((rc = ldap_simple_bind_s( ld, loginDN, password )) != LDAP_SUCCESS )
{
    printf("ldap_simple_bind_s: %s\n", ldap_err2string( rc ));
    ldap_unbind_s( ld );
    return 10;
}
printf("Bind and authentication to the server successful\n");

string a="(&(objectclass=person)(cn="+prenom+" "+nom+"))";
rc = ldap_search_ext_s(
            ld,                    /* LDAP session handle */
            searchBase,            /* container to search */
            LDAP_SCOPE_ONELEVEL,   /* search scope */
            a.c_str(),             /*search filter*/
            NULL,                  /* return all attributes */
            0,                     /* return attributes and values */
            NULL,                  /* server controls */
            NULL,                  /* client controls */
            &timeOut,              /* search timeout */
            LDAP_NO_LIMIT,         /* no size limit */
            &searchResult );       /* returned results */
if ( rc != LDAP_SUCCESS )
{
    cout<<rc<<endl;
    printf("ldap_search_ext_s: %s\n", ldap_err2string( rc ));
    ldap_msgfree( searchResult );
    ldap_unbind_s( ld );
    return  20 ;
}

我找到了答案 我必须使用端口 3268 而不是 389