summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-08-13 06:27:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:58 -0500
commitcd5421b8ab189a35fe4f546ed1a4893f20e24ab3 (patch)
tree087bb4710de0e934294fd2cfaef4510d340f2f06
parent01b58ebf83eca8b3909f3ba5becd6615bb89039f (diff)
downloadsamba-cd5421b8ab189a35fe4f546ed1a4893f20e24ab3.tar.gz
samba-cd5421b8ab189a35fe4f546ed1a4893f20e24ab3.tar.bz2
samba-cd5421b8ab189a35fe4f546ed1a4893f20e24ab3.zip
r1803: more progress on sasl binds, but decoding the response still fails
metze (This used to be commit f6c44201073df37881191509ffb7badee3baac71)
-rw-r--r--source4/libcli/ldap/ldap.c30
-rw-r--r--source4/libcli/ldap/ldap.h2
2 files changed, 28 insertions, 4 deletions
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 3048c94114..b17d5dc461 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -1066,6 +1066,26 @@ static void ldap_decode_response(TALLOC_CTX *mem_ctx,
asn1_end_tag(data);
}
+static void ldap_decode_BindResponse(TALLOC_CTX *mem_ctx,
+ ASN1_DATA *data,
+ enum ldap_request_tag tag,
+ struct ldap_BindResponse *BindResp)
+{
+ asn1_start_tag(data, ASN1_APPLICATION(tag));
+ asn1_read_enumerated(data, &BindResp->response.resultcode);
+ asn1_read_OctetString_talloc(mem_ctx, data, &BindResp->response.dn);
+ asn1_read_OctetString_talloc(mem_ctx, data, &BindResp->response.errormessage);
+ if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
+ DATA_BLOB tmp_blob = data_blob(NULL, 0);
+ asn1_read_OctetString(data, &tmp_blob);
+ BindResp->SASL.secblob = data_blob_talloc(mem_ctx, tmp_blob.data, tmp_blob.length);
+ data_blob_free(&tmp_blob);
+ } else {
+ BindResp->SASL.secblob = data_blob(NULL, 0);
+ }
+ asn1_end_tag(data);
+}
+
static BOOL add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
const struct ldap_attribute *attrib,
struct ldap_attribute **attribs,
@@ -1261,9 +1281,9 @@ BOOL ldap_decode(ASN1_DATA *data, struct ldap_message *msg)
case ASN1_APPLICATION(LDAP_TAG_BindResponse): {
struct ldap_BindResponse *r = &msg->r.BindResponse;
msg->type = LDAP_TAG_BindResponse;
- ldap_decode_response(msg->mem_ctx,
+ ldap_decode_BindResponse(msg->mem_ctx,
data, LDAP_TAG_BindResponse,
- &r->response);
+ r);
break;
}
@@ -1866,6 +1886,10 @@ int ldap_bind_sasl(struct ldap_connection *conn, const char *username, const cha
response = ldap_transaction(conn, msg);
destroy_ldap_message(msg);
+ if (!response) {
+ goto done;
+ }
+
result = response->r.BindResponse.response.resultcode;
if (result != LDAP_SUCCESS && result != LDAP_SASL_BIND_IN_PROGRESS) {
@@ -1873,7 +1897,7 @@ int ldap_bind_sasl(struct ldap_connection *conn, const char *username, const cha
}
status = gensec_update(conn->gensec, mem_ctx,
- response->r.BindResponse.SASL.creds,
+ response->r.BindResponse.SASL.secblob,
&output);
destroy_ldap_message(response);
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index fcd660f841..af322e783a 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -85,7 +85,7 @@ struct ldap_BindRequest {
struct ldap_BindResponse {
struct ldap_Result response;
union {
- DATA_BLOB creds;
+ DATA_BLOB secblob;
} SASL;
};