r3584: fix referral handling
authorStefan Metzmacher <metze@samba.org>
Sat, 6 Nov 2004 20:43:36 +0000 (20:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:35 +0000 (13:05 -0500)
metze
(This used to be commit 4868f1ea857e94f60dbde83bfb54def8a5ee728f)

source4/libcli/ldap/ldap.c
source4/libcli/ldap/ldap.h

index 315241e5b13098b84d3b7980f3f1df2fcdd9816b..2eea7b035acc7b3569e9bac3fbebbf7e62f18910 100644 (file)
@@ -361,9 +361,12 @@ static void ldap_encode_response(struct asn1_data *data, struct ldap_Result *res
        asn1_write_OctetString(data, result->errormessage,
                               (result->errormessage) ?
                               strlen(result->errormessage) : 0);
-       if (result->referral != NULL)
+       if (result->referral) {
+               asn1_push_tag(data, ASN1_CONTEXT(3));
                asn1_write_OctetString(data, result->referral,
                                       strlen(result->referral));
+               asn1_pop_tag(data);
+       }
 }
 
 BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result)
@@ -620,7 +623,10 @@ BOOL ldap_encode(struct ldap_message *msg, DATA_BLOB *result)
                break;
        }
        case LDAP_TAG_SearchResultReference: {
-/*             struct ldap_SearchResRef *r = &msg->r.SearchResultReference; */
+               struct ldap_SearchResRef *r = &msg->r.SearchResultReference;
+               asn1_push_tag(&data, ASN1_APPLICATION(msg->type));
+               asn1_write_OctetString(&data, r->referral, strlen(r->referral));
+               asn1_pop_tag(&data);
                break;
        }
        case LDAP_TAG_ExtendedRequest: {
@@ -957,8 +963,11 @@ BOOL ldap_decode(struct asn1_data *data, struct ldap_message *msg)
        }
 
        case ASN1_APPLICATION(LDAP_TAG_SearchResultReference): {
-/*             struct ldap_SearchResRef *r = &msg->r.SearchResultReference; */
+               struct ldap_SearchResRef *r = &msg->r.SearchResultReference;
                msg->type = LDAP_TAG_SearchResultReference;
+               asn1_start_tag(data, tag);
+               asn1_read_OctetString_talloc(msg->mem_ctx, data, &r->referral);
+               asn1_end_tag(data);
                break;
        }
 
index c27aba8d7af08ff129b69797929a3fd1278ae11f..65962bf5b5470f10584c00c18b442e32616576d4 100644 (file)
@@ -161,8 +161,7 @@ struct ldap_SearchResEntry {
 };
 
 struct ldap_SearchResRef {
-       int num_referrals;
-       const char **referrals;
+       const char *referral;
 };
 
 enum ldap_modify_type {