diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-10-09 23:59:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:42 -0500 |
commit | f49f6e0c83a8296bcaba3cb11b5fcaa55dd5ce5d (patch) | |
tree | 847b892002e942f0325f48157699c8b402efa467 | |
parent | 9d26f044a34bbc53a7621c7343cdcbbc752f99ac (diff) | |
download | samba-f49f6e0c83a8296bcaba3cb11b5fcaa55dd5ce5d.tar.gz samba-f49f6e0c83a8296bcaba3cb11b5fcaa55dd5ce5d.tar.bz2 samba-f49f6e0c83a8296bcaba3cb11b5fcaa55dd5ce5d.zip |
r2884: parse LDAP Control messages
metze
(This used to be commit e23dcb18870450be4252a0dba3e427f73291da25)
-rw-r--r-- | source4/libcli/ldap/ldap.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c index fbb5a21d84..7e12f42f06 100644 --- a/source4/libcli/ldap/ldap.c +++ b/source4/libcli/ldap/ldap.c @@ -1162,6 +1162,47 @@ BOOL ldap_decode(ASN1_DATA *data, struct ldap_message *msg) return False; } + msg->num_controls = 0; + msg->controls = NULL; + + if (asn1_peek_tag(data, ASN1_CONTEXT(0))) { + int i; + struct ldap_Control *ctrl = NULL; + + asn1_start_tag(data, ASN1_CONTEXT(0)); + + for (i=0; asn1_peek_tag(data, ASN1_SEQUENCE(0)); i++) { + asn1_start_tag(data, ASN1_SEQUENCE(0)); + + ctrl = talloc_realloc_p(msg->mem_ctx, ctrl, struct ldap_Control, i+1); + if (!ctrl) { + return False; + } + ctrl[i].oid = NULL; + ctrl[i].critical = False; + ctrl[i].value = data_blob(NULL, 0); + + asn1_read_OctetString_talloc(ctrl, data, &ctrl[i].oid); + + if (asn1_peek_tag(data, ASN1_BOOLEAN)) { + asn1_read_BOOLEAN(data, &ctrl[i].critical); + } + + if (asn1_peek_tag(data, ASN1_OCTET_STRING)) { + asn1_read_OctetString(data, &ctrl[i].value); + if (ctrl[i].value.data) { + talloc_steal(msg->mem_ctx, ctrl[i].value.data); + } + } + + asn1_end_tag(data); + } + msg->num_controls = i; + msg->controls = ctrl; + + asn1_end_tag(data); + } + asn1_end_tag(data); return ((!data->has_error) && (data->nesting == NULL)); } |