2 Unix SMB/CIFS mplementation.
3 LDAP protocol helper functions for SAMBA
5 Copyright (C) Simo Sorce 2005
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "../lib/util/asn1.h"
27 #include "libcli/ldap/libcli_ldap.h"
28 #include "libcli/ldap/ldap_proto.h"
29 #include "dsdb/samdb/samdb.h"
31 static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void *_out)
33 void **out = (void **)_out;
35 struct asn1_data *data = asn1_init(mem_ctx);
36 struct ldb_sort_resp_control *lsrc;
38 if (!data) return false;
40 if (!asn1_load(data, in)) {
44 lsrc = talloc(mem_ctx, struct ldb_sort_resp_control);
49 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
53 if (!asn1_read_enumerated(data, &(lsrc->result))) {
57 lsrc->attr_desc = NULL;
58 if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
59 if (!asn1_read_OctetString(data, mem_ctx, &attr)) {
62 lsrc->attr_desc = talloc_strndup(lsrc, (const char *)attr.data, attr.length);
63 if (!lsrc->attr_desc) {
68 if (!asn1_end_tag(data)) {
77 static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void *_out)
79 void **out = (void **)_out;
82 struct asn1_data *data = asn1_init(mem_ctx);
83 struct ldb_server_sort_control **lssc;
86 if (!data) return false;
88 if (!asn1_load(data, in)) {
92 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
98 for (num = 0; asn1_peek_tag(data, ASN1_SEQUENCE(0)); num++) {
99 lssc = talloc_realloc(mem_ctx, lssc, struct ldb_server_sort_control *, num + 2);
103 lssc[num] = talloc_zero(lssc, struct ldb_server_sort_control);
108 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
112 if (!asn1_read_OctetString(data, mem_ctx, &attr)) {
116 lssc[num]->attributeName = talloc_strndup(lssc[num], (const char *)attr.data, attr.length);
117 if (!lssc [num]->attributeName) {
121 if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(0))) {
122 if (!asn1_read_ContextSimple(data, mem_ctx, 0, &rule)) {
125 lssc[num]->orderingRule = talloc_strndup(lssc[num], (const char *)rule.data, rule.length);
126 if (!lssc[num]->orderingRule) {
131 if (asn1_peek_tag(data, ASN1_CONTEXT_SIMPLE(1))) {
133 if (!asn1_read_BOOLEAN_context(data, &reverse, 1)) {
136 lssc[num]->reverse = reverse;
139 if (!asn1_end_tag(data)) {
148 if (!asn1_end_tag(data)) {
157 static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void *_out)
159 void **out = (void **)_out;
160 struct asn1_data *data;
161 struct ldb_extended_dn_control *ledc;
163 /* The content of this control is optional */
164 if (in.length == 0) {
169 data = asn1_init(mem_ctx);
170 if (!data) return false;
172 if (!asn1_load(data, in)) {
176 ledc = talloc(mem_ctx, struct ldb_extended_dn_control);
181 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
185 if (!asn1_read_Integer(data, &(ledc->type))) {
189 if (!asn1_end_tag(data)) {
198 static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void *_out)
200 void **out = (void **)_out;
201 struct asn1_data *data = asn1_init(mem_ctx);
202 struct ldb_sd_flags_control *lsdfc;
204 if (!data) return false;
206 if (!asn1_load(data, in)) {
210 lsdfc = talloc(mem_ctx, struct ldb_sd_flags_control);
215 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
219 if (!asn1_read_Integer(data, (int *) &(lsdfc->secinfo_flags))) {
223 if (!asn1_end_tag(data)) {
232 static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void *_out)
234 void **out = (void **)_out;
235 struct asn1_data *data = asn1_init(mem_ctx);
236 struct ldb_search_options_control *lsoc;
238 if (!data) return false;
240 if (!asn1_load(data, in)) {
244 lsoc = talloc(mem_ctx, struct ldb_search_options_control);
249 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
253 if (!asn1_read_Integer(data, (int *) &(lsoc->search_options))) {
257 if (!asn1_end_tag(data)) {
266 static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void *_out)
268 void **out = (void **)_out;
270 struct asn1_data *data = asn1_init(mem_ctx);
271 struct ldb_paged_control *lprc;
273 if (!data) return false;
275 if (!asn1_load(data, in)) {
279 lprc = talloc(mem_ctx, struct ldb_paged_control);
284 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
288 if (!asn1_read_Integer(data, &(lprc->size))) {
292 if (!asn1_read_OctetString(data, mem_ctx, &cookie)) {
295 lprc->cookie_len = cookie.length;
296 if (lprc->cookie_len) {
297 lprc->cookie = talloc_memdup(lprc, cookie.data, cookie.length);
299 if (!(lprc->cookie)) {
306 if (!asn1_end_tag(data)) {
315 static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void *_out)
317 void **out = (void **)_out;
319 struct asn1_data *data = asn1_init(mem_ctx);
320 struct ldb_dirsync_control *ldc;
322 if (!data) return false;
324 if (!asn1_load(data, in)) {
328 ldc = talloc(mem_ctx, struct ldb_dirsync_control);
333 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
337 if (!asn1_read_Integer(data, &(ldc->flags))) {
341 if (!asn1_read_Integer(data, &(ldc->max_attributes))) {
345 if (!asn1_read_OctetString(data, mem_ctx, &cookie)) {
348 ldc->cookie_len = cookie.length;
349 if (ldc->cookie_len) {
350 ldc->cookie = talloc_memdup(ldc, cookie.data, cookie.length);
352 if (!(ldc->cookie)) {
359 if (!asn1_end_tag(data)) {
368 /* seem that this controls has 2 forms one in case it is used with
369 * a Search Request and another when used ina Search Response
371 static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void *_out)
373 void **out = (void **)_out;
374 DATA_BLOB source_attribute;
375 struct asn1_data *data = asn1_init(mem_ctx);
376 struct ldb_asq_control *lac;
378 if (!data) return false;
380 if (!asn1_load(data, in)) {
384 lac = talloc(mem_ctx, struct ldb_asq_control);
389 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
393 if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
395 if (!asn1_read_OctetString(data, mem_ctx, &source_attribute)) {
398 lac->src_attr_len = source_attribute.length;
399 if (lac->src_attr_len) {
400 lac->source_attribute = talloc_strndup(lac, (const char *)source_attribute.data, source_attribute.length);
402 if (!(lac->source_attribute)) {
406 lac->source_attribute = NULL;
411 } else if (asn1_peek_tag(data, ASN1_ENUMERATED)) {
413 if (!asn1_read_enumerated(data, &(lac->result))) {
423 if (!asn1_end_tag(data)) {
432 static bool decode_verify_name_request(void *mem_ctx, DATA_BLOB in, void *_out)
434 void **out = (void **)_out;
436 struct asn1_data *data = asn1_init(mem_ctx);
437 struct ldb_verify_name_control *lvnc;
440 if (!data) return false;
442 if (!asn1_load(data, in)) {
446 lvnc = talloc(mem_ctx, struct ldb_verify_name_control);
451 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
455 if (!asn1_read_Integer(data, &(lvnc->flags))) {
459 if (!asn1_read_OctetString(data, mem_ctx, &name)) {
464 len = utf16_len_n(name.data, name.length);
465 convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
467 (void **)&lvnc->gc, &lvnc->gc_len);
477 if (!asn1_end_tag(data)) {
485 static bool encode_verify_name_request(void *mem_ctx, void *in, DATA_BLOB *out)
487 struct ldb_verify_name_control *lvnc = talloc_get_type(in, struct ldb_verify_name_control);
488 struct asn1_data *data = asn1_init(mem_ctx);
491 if (!data) return false;
493 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
497 if (!asn1_write_Integer(data, lvnc->flags)) {
502 convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16,
503 lvnc->gc, lvnc->gc_len,
504 (void **)&gc_utf16.data, &gc_utf16.length);
505 if (!asn1_write_OctetString(data, gc_utf16.data, gc_utf16.length)) {
509 if (!asn1_write_OctetString(data, NULL, 0)) {
514 if (!asn1_pop_tag(data)) {
518 if (!asn1_extract_blob(data, mem_ctx, out)) {
527 static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out)
529 void **out = (void **)_out;
530 DATA_BLOB assertion_value, context_id;
531 struct asn1_data *data = asn1_init(mem_ctx);
532 struct ldb_vlv_req_control *lvrc;
534 if (!data) return false;
536 if (!asn1_load(data, in)) {
540 lvrc = talloc(mem_ctx, struct ldb_vlv_req_control);
545 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
549 if (!asn1_read_Integer(data, &(lvrc->beforeCount))) {
553 if (!asn1_read_Integer(data, &(lvrc->afterCount))) {
557 if (asn1_peek_tag(data, ASN1_CONTEXT(0))) {
561 if (!asn1_start_tag(data, ASN1_CONTEXT(0))) {
565 if (!asn1_read_Integer(data, &(lvrc->match.byOffset.offset))) {
569 if (!asn1_read_Integer(data, &(lvrc->match.byOffset.contentCount))) {
573 if (!asn1_end_tag(data)) { /*CONTEXT*/
581 if (!asn1_read_ContextSimple(data, mem_ctx, 1, &assertion_value)){
585 lvrc->match.gtOrEq.value_len = assertion_value.length;
586 if (lvrc->match.gtOrEq.value_len) {
587 lvrc->match.gtOrEq.value = talloc_memdup(lvrc, assertion_value.data, assertion_value.length);
589 if (!(lvrc->match.gtOrEq.value)) {
593 lvrc->match.gtOrEq.value = NULL;
597 if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
598 if (!asn1_read_OctetString(data, mem_ctx, &context_id)) {
601 lvrc->ctxid_len = context_id.length;
602 if (lvrc->ctxid_len) {
603 lvrc->contextId = talloc_memdup(lvrc, context_id.data, context_id.length);
605 if (!(lvrc->contextId)) {
609 lvrc->contextId = NULL;
612 lvrc->contextId = NULL;
616 if (!asn1_end_tag(data)) {
625 static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void *_out)
627 void **out = (void **)_out;
628 DATA_BLOB context_id;
629 struct asn1_data *data = asn1_init(mem_ctx);
630 struct ldb_vlv_resp_control *lvrc;
632 if (!data) return false;
634 if (!asn1_load(data, in)) {
638 lvrc = talloc(mem_ctx, struct ldb_vlv_resp_control);
643 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
647 if (!asn1_read_Integer(data, &(lvrc->targetPosition))) {
651 if (!asn1_read_Integer(data, &(lvrc->contentCount))) {
655 if (!asn1_read_enumerated(data, &(lvrc->vlv_result))) {
659 if (asn1_peek_tag(data, ASN1_OCTET_STRING)) {
660 if (!asn1_read_OctetString(data, mem_ctx, &context_id)) {
663 lvrc->contextId = talloc_memdup(lvrc, (const char *)context_id.data, context_id.length);
664 if (!lvrc->contextId) {
667 lvrc->ctxid_len = context_id.length;
669 lvrc->contextId = NULL;
673 if (!asn1_end_tag(data)) {
682 static bool encode_server_sort_response(void *mem_ctx, void *in, DATA_BLOB *out)
684 struct ldb_sort_resp_control *lsrc = talloc_get_type(in, struct ldb_sort_resp_control);
685 struct asn1_data *data = asn1_init(mem_ctx);
687 if (!data) return false;
689 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
693 if (!asn1_write_enumerated(data, lsrc->result)) {
697 if (lsrc->attr_desc) {
698 if (!asn1_write_OctetString(data, lsrc->attr_desc, strlen(lsrc->attr_desc))) {
703 if (!asn1_pop_tag(data)) {
707 if (!asn1_extract_blob(data, mem_ctx, out)) {
716 static bool encode_server_sort_request(void *mem_ctx, void *in, DATA_BLOB *out)
718 struct ldb_server_sort_control **lssc = talloc_get_type(in, struct ldb_server_sort_control *);
719 struct asn1_data *data = asn1_init(mem_ctx);
722 if (!data) return false;
724 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
730 SortKeyList ::= SEQUENCE OF SEQUENCE {
731 attributeType AttributeDescription,
732 orderingRule [0] MatchingRuleId OPTIONAL,
733 reverseOrder [1] BOOLEAN DEFAULT FALSE }
735 for (num = 0; lssc[num]; num++) {
736 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
740 if (!asn1_write_OctetString(data, lssc[num]->attributeName, strlen(lssc[num]->attributeName))) {
744 if (lssc[num]->orderingRule) {
745 DATA_BLOB order = data_blob_string_const(lssc[num]->orderingRule);
746 if (!asn1_write_ContextSimple(data, 0, &order)) {
751 if (lssc[num]->reverse) {
752 if (!asn1_write_BOOLEAN_context(data, lssc[num]->reverse, 1)) {
757 if (!asn1_pop_tag(data)) {
762 if (!asn1_pop_tag(data)) {
766 if (!asn1_extract_blob(data, mem_ctx, out)) {
775 static bool encode_extended_dn_request(void *mem_ctx, void *in, DATA_BLOB *out)
777 struct ldb_extended_dn_control *ledc = talloc_get_type(in, struct ldb_extended_dn_control);
778 struct asn1_data *data;
781 *out = data_blob(NULL, 0);
785 data = asn1_init(mem_ctx);
787 if (!data) return false;
789 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
793 if (!asn1_write_Integer(data, ledc->type)) {
797 if (!asn1_pop_tag(data)) {
801 if (!asn1_extract_blob(data, mem_ctx, out)) {
810 static bool encode_sd_flags_request(void *mem_ctx, void *in, DATA_BLOB *out)
812 struct ldb_sd_flags_control *lsdfc = talloc_get_type(in, struct ldb_sd_flags_control);
813 struct asn1_data *data = asn1_init(mem_ctx);
815 if (!data) return false;
817 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
821 if (!asn1_write_Integer(data, lsdfc->secinfo_flags)) {
825 if (!asn1_pop_tag(data)) {
829 if (!asn1_extract_blob(data, mem_ctx, out)) {
838 static bool encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
840 struct ldb_search_options_control *lsoc = talloc_get_type(in, struct ldb_search_options_control);
841 struct asn1_data *data = asn1_init(mem_ctx);
843 if (!data) return false;
845 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
849 if (!asn1_write_Integer(data, lsoc->search_options)) {
853 if (!asn1_pop_tag(data)) {
857 if (!asn1_extract_blob(data, mem_ctx, out)) {
866 static bool encode_paged_results_request(void *mem_ctx, void *in, DATA_BLOB *out)
868 struct ldb_paged_control *lprc = talloc_get_type(in, struct ldb_paged_control);
869 struct asn1_data *data = asn1_init(mem_ctx);
871 if (!data) return false;
873 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
877 if (!asn1_write_Integer(data, lprc->size)) {
881 if (!asn1_write_OctetString(data, lprc->cookie, lprc->cookie_len)) {
885 if (!asn1_pop_tag(data)) {
889 if (!asn1_extract_blob(data, mem_ctx, out)) {
898 /* seem that this controls has 2 forms one in case it is used with
899 * a Search Request and another when used ina Search Response
901 static bool encode_asq_control(void *mem_ctx, void *in, DATA_BLOB *out)
903 struct ldb_asq_control *lac = talloc_get_type(in, struct ldb_asq_control);
904 struct asn1_data *data = asn1_init(mem_ctx);
906 if (!data) return false;
908 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
914 if (!asn1_write_OctetString(data, lac->source_attribute, lac->src_attr_len)) {
918 if (!asn1_write_enumerated(data, lac->result)) {
923 if (!asn1_pop_tag(data)) {
927 if (!asn1_extract_blob(data, mem_ctx, out)) {
936 static bool encode_dirsync_request(void *mem_ctx, void *in, DATA_BLOB *out)
938 struct ldb_dirsync_control *ldc = talloc_get_type(in, struct ldb_dirsync_control);
939 struct asn1_data *data = asn1_init(mem_ctx);
941 if (!data) return false;
943 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
947 if (!asn1_write_Integer(data, ldc->flags)) {
951 if (!asn1_write_Integer(data, ldc->max_attributes)) {
955 if (!asn1_write_OctetString(data, ldc->cookie, ldc->cookie_len)) {
959 if (!asn1_pop_tag(data)) {
963 if (!asn1_extract_blob(data, mem_ctx, out)) {
972 static bool encode_vlv_request(void *mem_ctx, void *in, DATA_BLOB *out)
974 struct ldb_vlv_req_control *lvrc = talloc_get_type(in, struct ldb_vlv_req_control);
975 struct asn1_data *data = asn1_init(mem_ctx);
977 if (!data) return false;
979 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
983 if (!asn1_write_Integer(data, lvrc->beforeCount)) {
987 if (!asn1_write_Integer(data, lvrc->afterCount)) {
991 if (lvrc->type == 0) {
992 if (!asn1_push_tag(data, ASN1_CONTEXT(0))) {
996 if (!asn1_write_Integer(data, lvrc->match.byOffset.offset)) {
1000 if (!asn1_write_Integer(data, lvrc->match.byOffset.contentCount)) {
1004 if (!asn1_pop_tag(data)) { /*CONTEXT*/
1008 if (!asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(1))) {
1012 if (!asn1_write(data, lvrc->match.gtOrEq.value, lvrc->match.gtOrEq.value_len)) {
1016 if (!asn1_pop_tag(data)) { /*CONTEXT*/
1021 if (lvrc->ctxid_len) {
1022 if (!asn1_write_OctetString(data, lvrc->contextId, lvrc->ctxid_len)) {
1027 if (!asn1_pop_tag(data)) {
1031 if (!asn1_extract_blob(data, mem_ctx, out)) {
1040 static bool encode_vlv_response(void *mem_ctx, void *in, DATA_BLOB *out)
1042 struct ldb_vlv_resp_control *lvrc = talloc_get_type(in, struct ldb_vlv_resp_control);
1043 struct asn1_data *data = asn1_init(mem_ctx);
1045 if (!data) return false;
1047 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
1051 if (!asn1_write_Integer(data, lvrc->targetPosition)) {
1055 if (!asn1_write_Integer(data, lvrc->contentCount)) {
1059 if (!asn1_write_enumerated(data, lvrc->vlv_result)) {
1063 if (lvrc->ctxid_len) {
1064 if (!asn1_write_OctetString(data, lvrc->contextId, lvrc->ctxid_len)) {
1069 if (!asn1_pop_tag(data)) {
1073 if (!asn1_extract_blob(data, mem_ctx, out)) {
1082 static bool encode_openldap_dereference(void *mem_ctx, void *in, DATA_BLOB *out)
1084 struct dsdb_openldap_dereference_control *control = talloc_get_type(in, struct dsdb_openldap_dereference_control);
1086 struct asn1_data *data = asn1_init(mem_ctx);
1088 if (!data) return false;
1090 if (!control) return false;
1092 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
1096 for (i=0; control->dereference && control->dereference[i]; i++) {
1097 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
1100 if (!asn1_write_OctetString(data, control->dereference[i]->source_attribute, strlen(control->dereference[i]->source_attribute))) {
1103 if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
1106 for (j=0; control->dereference && control->dereference[i]->dereference_attribute[j]; j++) {
1107 if (!asn1_write_OctetString(data, control->dereference[i]->dereference_attribute[j],
1108 strlen(control->dereference[i]->dereference_attribute[j]))) {
1113 if (!asn1_pop_tag(data)) {
1116 if (!asn1_pop_tag(data)) {
1120 if (!asn1_pop_tag(data)) {
1124 if (!asn1_extract_blob(data, mem_ctx, out)) {
1132 static bool decode_openldap_dereference(void *mem_ctx, DATA_BLOB in, void *_out)
1134 void **out = (void **)_out;
1135 struct asn1_data *data = asn1_init(mem_ctx);
1136 struct dsdb_openldap_dereference_result_control *control;
1137 struct dsdb_openldap_dereference_result **r = NULL;
1139 if (!data) return false;
1141 control = talloc(mem_ctx, struct dsdb_openldap_dereference_result_control);
1142 if (!control) return false;
1144 if (!asn1_load(data, in)) {
1148 control = talloc(mem_ctx, struct dsdb_openldap_dereference_result_control);
1153 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
1157 while (asn1_tag_remaining(data) > 0) {
1158 r = talloc_realloc(control, r, struct dsdb_openldap_dereference_result *, i + 2);
1162 r[i] = talloc_zero(r, struct dsdb_openldap_dereference_result);
1167 if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
1171 if (!asn1_read_OctetString_talloc(r[i], data, &r[i]->source_attribute)) {
1174 if (!asn1_read_OctetString_talloc(r[i], data, &r[i]->dereferenced_dn)) {
1177 if (asn1_peek_tag(data, ASN1_CONTEXT(0))) {
1178 if (!asn1_start_tag(data, ASN1_CONTEXT(0))) {
1181 if (!ldap_decode_attribs_bare(r, data, &r[i]->attributes,
1182 &r[i]->num_attributes)) {
1185 if (!asn1_end_tag(data)) {
1189 if (!asn1_end_tag(data)) {
1196 if (!asn1_end_tag(data)) {
1200 control->attributes = r;
1206 static bool encode_flag_request(void *mem_ctx, void *in, DATA_BLOB *out)
1212 *out = data_blob(NULL, 0);
1216 static bool decode_flag_request(void *mem_ctx, DATA_BLOB in, void *_out)
1218 if (in.length != 0) {
1225 static const struct ldap_control_handler ldap_known_controls[] = {
1226 { LDB_CONTROL_PAGED_RESULTS_OID, decode_paged_results_request, encode_paged_results_request },
1227 { LDB_CONTROL_SD_FLAGS_OID, decode_sd_flags_request, encode_sd_flags_request },
1228 { LDB_CONTROL_DOMAIN_SCOPE_OID, decode_flag_request, encode_flag_request },
1229 { LDB_CONTROL_SEARCH_OPTIONS_OID, decode_search_options_request, encode_search_options_request },
1230 { LDB_CONTROL_NOTIFICATION_OID, decode_flag_request, encode_flag_request },
1231 { LDB_CONTROL_TREE_DELETE_OID, decode_flag_request, encode_flag_request },
1232 { LDB_CONTROL_SHOW_DELETED_OID, decode_flag_request, encode_flag_request },
1233 { LDB_CONTROL_SHOW_RECYCLED_OID, decode_flag_request, encode_flag_request },
1234 { LDB_CONTROL_SHOW_DEACTIVATED_LINK_OID, decode_flag_request, encode_flag_request },
1235 { LDB_CONTROL_EXTENDED_DN_OID, decode_extended_dn_request, encode_extended_dn_request },
1236 { LDB_CONTROL_SERVER_SORT_OID, decode_server_sort_request, encode_server_sort_request },
1237 { LDB_CONTROL_SORT_RESP_OID, decode_server_sort_response, encode_server_sort_response },
1238 { LDB_CONTROL_ASQ_OID, decode_asq_control, encode_asq_control },
1239 { LDB_CONTROL_DIRSYNC_OID, decode_dirsync_request, encode_dirsync_request },
1240 { LDB_CONTROL_DIRSYNC_EX_OID, decode_dirsync_request, encode_dirsync_request },
1241 { LDB_CONTROL_VLV_REQ_OID, decode_vlv_request, encode_vlv_request },
1242 { LDB_CONTROL_VLV_RESP_OID, decode_vlv_response, encode_vlv_response },
1243 { LDB_CONTROL_PERMISSIVE_MODIFY_OID, decode_flag_request, encode_flag_request },
1244 { LDB_CONTROL_SERVER_LAZY_COMMIT, decode_flag_request, encode_flag_request },
1245 { LDB_CONTROL_RODC_DCPROMO_OID, decode_flag_request, encode_flag_request },
1246 { LDB_CONTROL_RELAX_OID, decode_flag_request, encode_flag_request },
1247 { DSDB_OPENLDAP_DEREFERENCE_CONTROL, decode_openldap_dereference, encode_openldap_dereference },
1248 { LDB_CONTROL_VERIFY_NAME_OID, decode_verify_name_request, encode_verify_name_request },
1250 /* the following are internal only, with a network
1252 { DSDB_CONTROL_BYPASS_PASSWORD_HASH_OID, decode_flag_request, encode_flag_request },
1254 /* all the ones below are internal only, and have no network
1256 { DSDB_CONTROL_CURRENT_PARTITION_OID, NULL, NULL },
1257 { DSDB_CONTROL_REPLICATED_UPDATE_OID, NULL, NULL },
1258 { DSDB_CONTROL_DN_STORAGE_FORMAT_OID, NULL, NULL },
1259 { LDB_CONTROL_RECALCULATE_SD_OID, NULL, NULL },
1260 { LDB_CONTROL_REVEAL_INTERNALS, NULL, NULL },
1261 { LDB_CONTROL_AS_SYSTEM_OID, NULL, NULL },
1262 { DSDB_CONTROL_PASSWORD_CHANGE_STATUS_OID, NULL, NULL },
1263 { DSDB_CONTROL_PASSWORD_HASH_VALUES_OID, NULL, NULL },
1264 { DSDB_CONTROL_PASSWORD_CHANGE_OID, NULL, NULL },
1265 { DSDB_CONTROL_APPLY_LINKS, NULL, NULL },
1266 { LDB_CONTROL_BYPASS_OPERATIONAL_OID, NULL, NULL },
1267 { DSDB_CONTROL_CHANGEREPLMETADATA_OID, NULL, NULL },
1268 { LDB_CONTROL_PROVISION_OID, NULL, NULL },
1269 { DSDB_EXTENDED_REPLICATED_OBJECTS_OID, NULL, NULL },
1270 { DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, NULL, NULL },
1271 { DSDB_EXTENDED_ALLOCATE_RID_POOL, NULL, NULL },
1272 { DSDB_CONTROL_NO_GLOBAL_CATALOG, NULL, NULL },
1273 { DSDB_EXTENDED_SCHEMA_UPGRADE_IN_PROGRESS_OID, NULL, NULL },
1274 { NULL, NULL, NULL }
1277 const struct ldap_control_handler *samba_ldap_control_handlers(void)
1279 return ldap_known_controls;