这是我正在建立start tls扩展操作的代码的一部分。在start tls.
执行后绑定不工作。BerElement *ber;//extended
struct berval *bv;
char *retoid;
struct berval *retdata;
struct berval oid;
oid.bv_val=(char*)LDAP_EXOP_START_TLS;
oid.bv_len=strlen(oid.bv_val);
ber=ber_alloc_t(LBER_USE_DER);
cout<<"ber: "<<ber<<"n";
ber_printf(ber,"{");
ber_printf(ber,"tO",LDAP_EXOP_START_TLS,oid);
ber_printf(ber,"N}");
res=ber_flatten(ber,&bv);
ber_free(ber,1);
cout<<"berf: "<<res<<"n";
res=ldap_extended_operation_s(ldap, LDAP_EXOP_START_TLS, bv, NULL, NULL, &retoid, &retdata);
cout<<res<<"n";
res = ldap_simple_bind_s(ldap, user_dn,pass);//binds
cout<<"bind: "<<res<<"n";
使用ldap_start_tls_s()代替ldap_extended_operation_s()函数.
ldap_start_tls_s()在开始任何通信之前自动发送请求以检查服务器上的StartTLS选项。详见手册