r19735: report the LDAP error code in the CLDAP replies to the caller
authorStefan Metzmacher <metze@samba.org>
Thu, 16 Nov 2006 10:42:07 +0000 (10:42 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:28:16 +0000 (14:28 -0500)
metze

source/libcli/cldap/cldap.c

index 94887ef6971e5e5f207483f7059a5070c1ae3724..9dfa8e81b1441a235ce470c74c44fb0a4bc63585 100644 (file)
@@ -450,7 +450,7 @@ NTSTATUS cldap_search_recv(struct cldap_request *req,
 
        if (!ldap_decode(&req->asn1, ldap_msg)) {
                talloc_free(req);
-               return NT_STATUS_INVALID_PARAMETER;
+               return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
        }
 
        ZERO_STRUCT(io->out);
@@ -464,13 +464,13 @@ NTSTATUS cldap_search_recv(struct cldap_request *req,
                /* decode the 2nd part */
                if (!ldap_decode(&req->asn1, ldap_msg)) {
                        talloc_free(req);
-                       return NT_STATUS_INVALID_PARAMETER;
+                       return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
                }
        }
 
        if (ldap_msg->type != LDAP_TAG_SearchResultDone) {
                talloc_free(req);
-               return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
+               return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
        }
 
        io->out.result = talloc(mem_ctx, struct ldap_Result);
@@ -478,6 +478,10 @@ NTSTATUS cldap_search_recv(struct cldap_request *req,
        *io->out.result = ldap_msg->r.SearchResultDone;
 
        talloc_free(req);
+
+       if (io->out.result->resultcode != LDAP_SUCCESS) {
+               return NT_STATUS_LDAP(io->out.result->resultcode);
+       }
        return NT_STATUS_OK;
 }