2 Unix SMB/CIFS implementation.
3 Samba utility functions
5 Copyright (C) Andrew Tridgell 2009
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "ldb_module.h"
25 #include "librpc/ndr/libndr.h"
26 #include "dsdb/samdb/ldb_modules/util.h"
27 #include "dsdb/samdb/samdb.h"
29 #include "libcli/security/security.h"
32 search for attrs on one DN, in the modules below
34 int dsdb_module_search_dn(struct ldb_module *module,
36 struct ldb_result **_res,
37 struct ldb_dn *basedn,
38 const char * const *attrs,
42 struct ldb_request *req;
44 struct ldb_result *res;
46 tmp_ctx = talloc_new(mem_ctx);
48 res = talloc_zero(tmp_ctx, struct ldb_result);
51 return LDB_ERR_OPERATIONS_ERROR;
54 ret = ldb_build_search_req(&req, ldb_module_get_ctx(module), tmp_ctx,
61 ldb_search_default_callback,
63 if (ret != LDB_SUCCESS) {
68 ret = dsdb_request_add_controls(req, dsdb_flags);
69 if (ret != LDB_SUCCESS) {
74 ret = ldb_next_request(module, req);
75 if (ret == LDB_SUCCESS) {
76 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
79 if (ret != LDB_SUCCESS) {
84 if (res->count != 1) {
85 /* we may be reading a DB that does not have the 'check base on search' option... */
86 ret = LDB_ERR_NO_SUCH_OBJECT;
87 ldb_asprintf_errstring(ldb_module_get_ctx(module),
88 "dsdb_module_search_dn: did not find base dn %s (%d results)",
89 ldb_dn_get_linearized(basedn), res->count);
91 *_res = talloc_steal(mem_ctx, res);
98 search for attrs in the modules below
100 int dsdb_module_search(struct ldb_module *module,
102 struct ldb_result **_res,
103 struct ldb_dn *basedn, enum ldb_scope scope,
104 const char * const *attrs,
106 const char *format, ...) _PRINTF_ATTRIBUTE(8, 9)
109 struct ldb_request *req;
111 struct ldb_result *res;
115 tmp_ctx = talloc_new(mem_ctx);
118 va_start(ap, format);
119 expression = talloc_vasprintf(tmp_ctx, format, ap);
123 talloc_free(tmp_ctx);
124 return LDB_ERR_OPERATIONS_ERROR;
130 res = talloc_zero(tmp_ctx, struct ldb_result);
132 talloc_free(tmp_ctx);
133 return LDB_ERR_OPERATIONS_ERROR;
136 ret = ldb_build_search_req(&req, ldb_module_get_ctx(module), tmp_ctx,
143 ldb_search_default_callback,
145 if (ret != LDB_SUCCESS) {
146 talloc_free(tmp_ctx);
150 ret = dsdb_request_add_controls(req, dsdb_flags);
151 if (ret != LDB_SUCCESS) {
152 talloc_free(tmp_ctx);
156 if (dsdb_flags & DSDB_FLAG_OWN_MODULE) {
157 const struct ldb_module_ops *ops = ldb_module_get_ops(module);
158 ret = ops->search(module, req);
159 } else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
160 ret = ldb_request(ldb_module_get_ctx(module), req);
162 SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
163 ret = ldb_next_request(module, req);
165 if (ret == LDB_SUCCESS) {
166 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
170 if (ret == LDB_SUCCESS) {
171 *_res = talloc_steal(mem_ctx, res);
173 talloc_free(tmp_ctx);
178 find a DN given a GUID. This searches across all partitions
180 int dsdb_module_dn_by_guid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
181 const struct GUID *guid, struct ldb_dn **dn)
183 struct ldb_result *res;
184 const char *attrs[] = { NULL };
185 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
188 ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
190 DSDB_FLAG_NEXT_MODULE |
191 DSDB_SEARCH_SHOW_DELETED |
192 DSDB_SEARCH_SEARCH_ALL_PARTITIONS |
193 DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT,
194 "objectGUID=%s", GUID_string(tmp_ctx, guid));
195 if (ret != LDB_SUCCESS) {
196 talloc_free(tmp_ctx);
199 if (res->count == 0) {
200 talloc_free(tmp_ctx);
201 return LDB_ERR_NO_SUCH_OBJECT;
203 if (res->count != 1) {
204 ldb_asprintf_errstring(ldb_module_get_ctx(module), "More than one object found matching objectGUID %s\n",
205 GUID_string(tmp_ctx, guid));
206 talloc_free(tmp_ctx);
207 return LDB_ERR_OPERATIONS_ERROR;
210 *dn = talloc_steal(mem_ctx, res->msgs[0]->dn);
212 talloc_free(tmp_ctx);
217 find a GUID given a DN.
219 int dsdb_module_guid_by_dn(struct ldb_module *module, struct ldb_dn *dn, struct GUID *guid)
221 const char *attrs[] = { NULL };
222 struct ldb_result *res;
223 TALLOC_CTX *tmp_ctx = talloc_new(module);
227 ret = dsdb_module_search_dn(module, tmp_ctx, &res, dn, attrs,
228 DSDB_SEARCH_SHOW_DELETED|
229 DSDB_SEARCH_SHOW_EXTENDED_DN);
230 if (ret != LDB_SUCCESS) {
231 ldb_asprintf_errstring(ldb_module_get_ctx(module), "Failed to find GUID for %s",
232 ldb_dn_get_linearized(dn));
233 talloc_free(tmp_ctx);
237 status = dsdb_get_extended_dn_guid(res->msgs[0]->dn, guid, "GUID");
238 if (!NT_STATUS_IS_OK(status)) {
239 talloc_free(tmp_ctx);
240 return LDB_ERR_OPERATIONS_ERROR;
243 talloc_free(tmp_ctx);
248 a ldb_modify request operating on modules below the
251 int dsdb_module_modify(struct ldb_module *module,
252 const struct ldb_message *message,
255 struct ldb_request *mod_req;
257 struct ldb_context *ldb = ldb_module_get_ctx(module);
258 TALLOC_CTX *tmp_ctx = talloc_new(module);
259 struct ldb_result *res;
261 res = talloc_zero(tmp_ctx, struct ldb_result);
263 talloc_free(tmp_ctx);
264 return LDB_ERR_OPERATIONS_ERROR;
267 ret = ldb_build_mod_req(&mod_req, ldb, tmp_ctx,
271 ldb_modify_default_callback,
273 if (ret != LDB_SUCCESS) {
274 talloc_free(tmp_ctx);
278 ret = dsdb_request_add_controls(mod_req, dsdb_flags);
279 if (ret != LDB_SUCCESS) {
280 talloc_free(tmp_ctx);
284 /* Run the new request */
285 if (dsdb_flags & DSDB_FLAG_OWN_MODULE) {
286 const struct ldb_module_ops *ops = ldb_module_get_ops(module);
287 ret = ops->modify(module, mod_req);
288 } else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
289 ret = ldb_request(ldb_module_get_ctx(module), mod_req);
291 SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
292 ret = ldb_next_request(module, mod_req);
294 if (ret == LDB_SUCCESS) {
295 ret = ldb_wait(mod_req->handle, LDB_WAIT_ALL);
298 talloc_free(tmp_ctx);
305 a ldb_rename request operating on modules below the
308 int dsdb_module_rename(struct ldb_module *module,
309 struct ldb_dn *olddn, struct ldb_dn *newdn,
312 struct ldb_request *req;
314 struct ldb_context *ldb = ldb_module_get_ctx(module);
315 TALLOC_CTX *tmp_ctx = talloc_new(module);
316 struct ldb_result *res;
318 res = talloc_zero(tmp_ctx, struct ldb_result);
320 talloc_free(tmp_ctx);
321 return LDB_ERR_OPERATIONS_ERROR;
324 ret = ldb_build_rename_req(&req, ldb, tmp_ctx,
329 ldb_modify_default_callback,
331 if (ret != LDB_SUCCESS) {
332 talloc_free(tmp_ctx);
336 ret = dsdb_request_add_controls(req, dsdb_flags);
337 if (ret != LDB_SUCCESS) {
338 talloc_free(tmp_ctx);
342 /* Run the new request */
343 if (dsdb_flags & DSDB_FLAG_OWN_MODULE) {
344 const struct ldb_module_ops *ops = ldb_module_get_ops(module);
345 ret = ops->rename(module, req);
346 } else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
347 ret = ldb_request(ldb_module_get_ctx(module), req);
349 SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
350 ret = ldb_next_request(module, req);
352 if (ret == LDB_SUCCESS) {
353 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
356 talloc_free(tmp_ctx);
361 a ldb_add request operating on modules below the
364 int dsdb_module_add(struct ldb_module *module,
365 const struct ldb_message *message,
368 struct ldb_request *req;
370 struct ldb_context *ldb = ldb_module_get_ctx(module);
371 TALLOC_CTX *tmp_ctx = talloc_new(module);
372 struct ldb_result *res;
374 res = talloc_zero(tmp_ctx, struct ldb_result);
376 talloc_free(tmp_ctx);
377 return LDB_ERR_OPERATIONS_ERROR;
380 ret = ldb_build_add_req(&req, ldb, tmp_ctx,
384 ldb_modify_default_callback,
386 if (ret != LDB_SUCCESS) {
387 talloc_free(tmp_ctx);
391 ret = dsdb_request_add_controls(req, dsdb_flags);
392 if (ret != LDB_SUCCESS) {
393 talloc_free(tmp_ctx);
397 /* Run the new request */
398 if (dsdb_flags & DSDB_FLAG_OWN_MODULE) {
399 const struct ldb_module_ops *ops = ldb_module_get_ops(module);
400 ret = ops->add(module, req);
401 } else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
402 ret = ldb_request(ldb_module_get_ctx(module), req);
404 SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
405 ret = ldb_next_request(module, req);
407 if (ret == LDB_SUCCESS) {
408 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
411 talloc_free(tmp_ctx);
416 a ldb_delete request operating on modules below the
419 int dsdb_module_del(struct ldb_module *module,
423 struct ldb_request *req;
425 struct ldb_context *ldb = ldb_module_get_ctx(module);
426 TALLOC_CTX *tmp_ctx = talloc_new(module);
427 struct ldb_result *res;
429 res = talloc_zero(tmp_ctx, struct ldb_result);
431 talloc_free(tmp_ctx);
432 return LDB_ERR_OPERATIONS_ERROR;
435 ret = ldb_build_del_req(&req, ldb, tmp_ctx,
439 ldb_modify_default_callback,
441 if (ret != LDB_SUCCESS) {
442 talloc_free(tmp_ctx);
446 ret = dsdb_request_add_controls(req, dsdb_flags);
447 if (ret != LDB_SUCCESS) {
448 talloc_free(tmp_ctx);
452 /* Run the new request */
453 if (dsdb_flags & DSDB_FLAG_OWN_MODULE) {
454 const struct ldb_module_ops *ops = ldb_module_get_ops(module);
455 ret = ops->del(module, req);
456 } else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
457 ret = ldb_request(ldb_module_get_ctx(module), req);
459 SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
460 ret = ldb_next_request(module, req);
462 if (ret == LDB_SUCCESS) {
463 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
466 talloc_free(tmp_ctx);
470 const struct dsdb_class * get_last_structural_class(const struct dsdb_schema *schema,const struct ldb_message_element *element)
472 const struct dsdb_class *last_class = NULL;
475 for (i = 0; i < element->num_values; i++){
476 const struct dsdb_class *tmp_class = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &element->values[i]);
478 if(tmp_class == NULL) {
482 if(tmp_class->objectClassCategory > 1) {
487 last_class = tmp_class;
489 if (tmp_class->subClass_order > last_class->subClass_order)
490 last_class = tmp_class;
498 check if a single valued link has multiple non-deleted values
500 This is needed when we will be using the RELAX control to stop
501 ldb_tdb from checking single valued links
503 int dsdb_check_single_valued_link(const struct dsdb_attribute *attr,
504 const struct ldb_message_element *el)
506 bool found_active = false;
509 if (!(attr->ldb_schema_attribute->flags & LDB_ATTR_FLAG_SINGLE_VALUE) ||
510 el->num_values < 2) {
514 for (i=0; i<el->num_values; i++) {
515 if (!dsdb_dn_is_deleted_val(&el->values[i])) {
517 return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
526 int dsdb_check_optional_feature(struct ldb_module *module, struct ldb_dn *scope,
527 struct GUID op_feature_guid, bool *feature_enabled)
530 struct ldb_context *ldb = ldb_module_get_ctx(module);
531 struct ldb_result *res;
532 struct ldb_dn *search_dn;
533 struct GUID search_guid;
534 const char *attrs[] = {"msDS-EnabledFeature", NULL};
537 struct ldb_message_element *el;
539 *feature_enabled = false;
541 tmp_ctx = talloc_new(ldb);
543 ret = ldb_search(ldb, tmp_ctx, &res,
544 scope, LDB_SCOPE_BASE, attrs,
546 if (ret != LDB_SUCCESS) {
547 ldb_asprintf_errstring(ldb,
548 "Could no find the scope object - dn: %s\n",
549 ldb_dn_get_linearized(scope));
550 talloc_free(tmp_ctx);
551 return LDB_ERR_OPERATIONS_ERROR;
553 if (res->msgs[0]->num_elements > 0) {
555 el = ldb_msg_find_element(res->msgs[0],"msDS-EnabledFeature");
557 attrs[0] = "msDS-OptionalFeatureGUID";
559 for (i=0; i<el->num_values; i++) {
560 search_dn = ldb_dn_from_ldb_val(tmp_ctx, ldb, &el->values[i]);
562 ret = ldb_search(ldb, tmp_ctx, &res,
563 search_dn, LDB_SCOPE_BASE, attrs,
565 if (ret != LDB_SUCCESS) {
566 ldb_asprintf_errstring(ldb,
567 "Could no find object dn: %s\n",
568 ldb_dn_get_linearized(search_dn));
569 talloc_free(tmp_ctx);
570 return LDB_ERR_OPERATIONS_ERROR;
573 search_guid = samdb_result_guid(res->msgs[0], "msDS-OptionalFeatureGUID");
575 if (GUID_compare(&search_guid, &op_feature_guid) == 0){
576 *feature_enabled = true;
581 talloc_free(tmp_ctx);
586 find a 'reference' DN that points at another object
587 (eg. serverReference, rIDManagerReference etc)
589 int dsdb_module_reference_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx, struct ldb_dn *base,
590 const char *attribute, struct ldb_dn **dn)
592 const char *attrs[2];
593 struct ldb_result *res;
596 attrs[0] = attribute;
599 ret = dsdb_module_search_dn(module, mem_ctx, &res, base, attrs, 0);
600 if (ret != LDB_SUCCESS) {
604 *dn = ldb_msg_find_attr_as_dn(ldb_module_get_ctx(module),
605 mem_ctx, res->msgs[0], attribute);
608 return LDB_ERR_NO_SUCH_ATTRIBUTE;
616 find the RID Manager$ DN via the rIDManagerReference attribute in the
619 int dsdb_module_rid_manager_dn(struct ldb_module *module, TALLOC_CTX *mem_ctx, struct ldb_dn **dn)
621 return dsdb_module_reference_dn(module, mem_ctx,
622 ldb_get_default_basedn(ldb_module_get_ctx(module)),
623 "rIDManagerReference", dn);
628 update an integer attribute safely via a constrained delete/add
630 int dsdb_module_constrainted_update_integer(struct ldb_module *module, struct ldb_dn *dn,
631 const char *attr, uint64_t old_val, uint64_t new_val)
633 struct ldb_message *msg;
634 struct ldb_message_element *el;
635 struct ldb_val v1, v2;
639 msg = ldb_msg_new(module);
642 ret = ldb_msg_add_empty(msg, attr, LDB_FLAG_MOD_DELETE, &el);
643 if (ret != LDB_SUCCESS) {
649 vstring = talloc_asprintf(msg, "%llu", (unsigned long long)old_val);
651 ldb_module_oom(module);
653 return LDB_ERR_OPERATIONS_ERROR;
655 v1 = data_blob_string_const(vstring);
657 ret = ldb_msg_add_empty(msg, attr, LDB_FLAG_MOD_ADD, &el);
658 if (ret != LDB_SUCCESS) {
664 vstring = talloc_asprintf(msg, "%llu", (unsigned long long)new_val);
666 ldb_module_oom(module);
668 return LDB_ERR_OPERATIONS_ERROR;
670 v2 = data_blob_string_const(vstring);
672 ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
678 used to chain to the callers callback
680 int dsdb_next_callback(struct ldb_request *req, struct ldb_reply *ares)
682 struct ldb_request *up_req = talloc_get_type(req->context, struct ldb_request);
684 talloc_steal(up_req, req);
685 return up_req->callback(up_req, ares);
690 set an integer attribute
692 int dsdb_module_set_integer(struct ldb_module *module, struct ldb_dn *dn,
693 const char *attr, uint64_t new_val)
695 struct ldb_message *msg;
698 msg = ldb_msg_new(module);
701 ret = ldb_msg_add_fmt(msg, attr, "%llu", (unsigned long long)new_val);
702 if (ret != LDB_SUCCESS) {
706 msg->elements[0].flags = LDB_FLAG_MOD_REPLACE;
708 ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
714 load the uSNHighest and the uSNUrgent attributes from the @REPLCHANGED
715 object for a partition
717 int dsdb_module_load_partition_usn(struct ldb_module *module, struct ldb_dn *dn,
718 uint64_t *uSN, uint64_t *urgent_uSN)
720 struct ldb_context *ldb = ldb_module_get_ctx(module);
721 struct ldb_request *req;
723 TALLOC_CTX *tmp_ctx = talloc_new(module);
724 struct dsdb_control_current_partition *p_ctrl;
725 struct ldb_result *res;
727 res = talloc_zero(tmp_ctx, struct ldb_result);
729 talloc_free(tmp_ctx);
730 return LDB_ERR_OPERATIONS_ERROR;
733 ret = ldb_build_search_req(&req, ldb, tmp_ctx,
734 ldb_dn_new(tmp_ctx, ldb, "@REPLCHANGED"),
738 res, ldb_search_default_callback,
740 if (ret != LDB_SUCCESS) {
741 talloc_free(tmp_ctx);
745 p_ctrl = talloc(req, struct dsdb_control_current_partition);
746 if (p_ctrl == NULL) {
747 talloc_free(tmp_ctx);
748 return LDB_ERR_OPERATIONS_ERROR;
750 p_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
754 ret = ldb_request_add_control(req,
755 DSDB_CONTROL_CURRENT_PARTITION_OID,
757 if (ret != LDB_SUCCESS) {
758 talloc_free(tmp_ctx);
762 /* Run the new request */
763 ret = ldb_next_request(module, req);
765 if (ret == LDB_SUCCESS) {
766 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
769 if (ret == LDB_ERR_NO_SUCH_OBJECT || ret == LDB_ERR_INVALID_DN_SYNTAX) {
770 /* it hasn't been created yet, which means
771 an implicit value of zero */
773 talloc_free(tmp_ctx);
777 if (ret != LDB_SUCCESS) {
778 talloc_free(tmp_ctx);
782 if (res->count < 1) {
788 *uSN = ldb_msg_find_attr_as_uint64(res->msgs[0], "uSNHighest", 0);
790 *urgent_uSN = ldb_msg_find_attr_as_uint64(res->msgs[0], "uSNUrgent", 0);
794 talloc_free(tmp_ctx);
800 save uSNHighest and uSNUrgent attributes in the @REPLCHANGED object for a
803 int dsdb_module_save_partition_usn(struct ldb_module *module, struct ldb_dn *dn,
804 uint64_t uSN, uint64_t urgent_uSN)
806 struct ldb_context *ldb = ldb_module_get_ctx(module);
807 struct ldb_request *req;
808 struct ldb_message *msg;
809 struct dsdb_control_current_partition *p_ctrl;
811 struct ldb_result *res;
813 msg = ldb_msg_new(module);
815 return LDB_ERR_OPERATIONS_ERROR;
818 msg->dn = ldb_dn_new(msg, ldb, "@REPLCHANGED");
819 if (msg->dn == NULL) {
821 return LDB_ERR_OPERATIONS_ERROR;
824 res = talloc_zero(msg, struct ldb_result);
827 return LDB_ERR_OPERATIONS_ERROR;
830 ret = ldb_msg_add_fmt(msg, "uSNHighest", "%llu", (unsigned long long)uSN);
831 if (ret != LDB_SUCCESS) {
835 msg->elements[0].flags = LDB_FLAG_MOD_REPLACE;
837 /* urgent_uSN is optional so may not be stored */
839 ret = ldb_msg_add_fmt(msg, "uSNUrgent", "%llu", (unsigned long long)urgent_uSN);
840 if (ret != LDB_SUCCESS) {
844 msg->elements[1].flags = LDB_FLAG_MOD_REPLACE;
848 p_ctrl = talloc(msg, struct dsdb_control_current_partition);
849 if (p_ctrl == NULL) {
851 return LDB_ERR_OPERATIONS_ERROR;
853 p_ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
855 ret = ldb_build_mod_req(&req, ldb, msg,
859 ldb_modify_default_callback,
862 if (ret != LDB_SUCCESS) {
867 ret = ldb_request_add_control(req,
868 DSDB_CONTROL_CURRENT_PARTITION_OID,
870 if (ret != LDB_SUCCESS) {
875 /* Run the new request */
876 ret = ldb_next_request(module, req);
878 if (ret == LDB_SUCCESS) {
879 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
881 if (ret == LDB_ERR_NO_SUCH_OBJECT) {
882 ret = ldb_build_add_req(&req, ldb, msg,
886 ldb_modify_default_callback,
896 bool dsdb_module_am_system(struct ldb_module *module)
898 struct ldb_context *ldb = ldb_module_get_ctx(module);
899 struct auth_session_info *session_info
900 = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo");
901 return security_session_user_level(session_info, NULL) == SECURITY_SYSTEM;
905 check if the recyclebin is enabled
907 int dsdb_recyclebin_enabled(struct ldb_module *module, bool *enabled)
909 struct ldb_context *ldb = ldb_module_get_ctx(module);
910 struct ldb_dn *partitions_dn;
911 struct GUID recyclebin_guid;
914 partitions_dn = samdb_partitions_dn(ldb, module);
916 GUID_from_string(DS_GUID_FEATURE_RECYCLE_BIN, &recyclebin_guid);
918 ret = dsdb_check_optional_feature(module, partitions_dn, recyclebin_guid, enabled);
919 if (ret != LDB_SUCCESS) {
920 ldb_asprintf_errstring(ldb, "Could not verify if Recycle Bin is enabled \n");
921 talloc_free(partitions_dn);
922 return LDB_ERR_UNWILLING_TO_PERFORM;
925 talloc_free(partitions_dn);
929 bool is_attr_in_list(const char * const * attrs, const char *attr)
933 for (i = 0; attrs[i]; i++) {
934 if (ldb_attr_cmp(attrs[i], attr) == 0)