- while (conn->send_queue) {
- struct ldap_request *req = conn->send_queue;
- size_t nsent;
- NTSTATUS status;
-
- status = tls_socket_send(conn->tls, &req->data, &nsent);
- if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
- break;
- }
- if (!NT_STATUS_IS_OK(status)) {
- ldap_connection_dead(conn);
- return;
- }
-
- req->data.data += nsent;
- req->data.length -= nsent;
- if (req->data.length == 0) {
- req->state = LDAP_REQUEST_PENDING;
- DLIST_REMOVE(conn->send_queue, req);
-
- /* some types of requests don't expect a reply */
- if (req->type == LDAP_TAG_AbandonRequest ||
- req->type == LDAP_TAG_UnbindRequest) {
- req->status = NT_STATUS_OK;
- req->state = LDAP_REQUEST_DONE;
- if (req->async.fn) {
- req->async.fn(req);
- }
- } else {
- DLIST_ADD(conn->pending, req);
- }
- }
- }
- if (conn->send_queue == NULL) {
- EVENT_FD_NOT_WRITEABLE(conn->event.fde);
+ struct ldap_connection *conn = talloc_get_type(private,
+ struct ldap_connection);
+ if (conn->enable_wrap) {
+ return ldap_decode_wrapped(conn, blob);