4 Copyright (C) Simo Sorce 2006-2008
5 Copyright (C) Nadezhda Ivanova 2009
6 Copyright (C) Anatoliy Atanasov 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/>.
25 * Component: ldb ACL module
27 * Description: Module that performs authorisation access checks based on the
28 * account's security context and the DACL of the object being polled.
29 * Only DACL checks implemented at this point
31 * Authors: Nadezhda Ivanova, Anatoliy Atanasov
35 #include "ldb_module.h"
36 #include "auth/auth.h"
37 #include "libcli/security/security.h"
38 #include "dsdb/samdb/samdb.h"
39 #include "librpc/gen_ndr/ndr_security.h"
40 #include "param/param.h"
41 #include "dsdb/samdb/ldb_modules/util.h"
42 #include "dsdb/samdb/ldb_modules/schema.h"
43 #include "lib/util/tsort.h"
44 #include "system/kerberos.h"
45 #include "auth/kerberos/kerberos.h"
47 struct extended_access_check_attribute {
49 const uint32_t requires_rights;
54 const char **password_attrs;
58 struct ldb_module *module;
59 struct ldb_request *req;
61 bool allowedAttributes;
62 bool allowedAttributesEffective;
63 bool allowedChildClasses;
64 bool allowedChildClassesEffective;
65 bool sDRightsEffective;
67 const char * const *attrs;
68 struct dsdb_schema *schema;
71 static int acl_module_init(struct ldb_module *module)
73 struct ldb_context *ldb;
74 struct acl_private *data;
78 static const char *attrs[] = { "passwordAttribute", NULL };
79 struct ldb_result *res;
80 struct ldb_message *msg;
81 struct ldb_message_element *password_attributes;
83 ldb = ldb_module_get_ctx(module);
85 ret = ldb_mod_register_control(module, LDB_CONTROL_SD_FLAGS_OID);
86 if (ret != LDB_SUCCESS) {
87 ldb_debug(ldb, LDB_DEBUG_ERROR,
88 "acl_module_init: Unable to register control with rootdse!\n");
89 return ldb_operr(ldb);
92 data = talloc(module, struct acl_private);
97 data->password_attrs = NULL;
98 data->acl_perform = lpcfg_parm_bool(ldb_get_opaque(ldb, "loadparm"),
99 NULL, "acl", "perform", false);
100 ldb_module_set_private(module, data);
102 mem_ctx = talloc_new(module);
107 ret = dsdb_module_search_dn(module, mem_ctx, &res,
108 ldb_dn_new(mem_ctx, ldb, "@KLUDGEACL"),
110 DSDB_FLAG_NEXT_MODULE, NULL);
111 if (ret != LDB_SUCCESS) {
114 if (res->count == 0) {
118 if (res->count > 1) {
119 talloc_free(mem_ctx);
120 return LDB_ERR_CONSTRAINT_VIOLATION;
125 password_attributes = ldb_msg_find_element(msg, "passwordAttribute");
126 if (!password_attributes) {
129 data->password_attrs = talloc_array(data, const char *, password_attributes->num_values + 1);
130 if (!data->password_attrs) {
131 talloc_free(mem_ctx);
134 for (i=0; i < password_attributes->num_values; i++) {
135 data->password_attrs[i] = (const char *)password_attributes->values[i].data;
136 talloc_steal(data->password_attrs, password_attributes->values[i].data);
138 data->password_attrs[i] = NULL;
141 talloc_free(mem_ctx);
142 return ldb_next_init(module);
145 static int acl_allowedAttributes(struct ldb_module *module,
146 const struct dsdb_schema *schema,
147 struct ldb_message *sd_msg,
148 struct ldb_message *msg,
149 struct acl_context *ac)
151 struct ldb_message_element *oc_el;
152 struct ldb_context *ldb = ldb_module_get_ctx(module);
154 const char **attr_list;
157 /* If we don't have a schema yet, we can't do anything... */
158 if (schema == NULL) {
159 ldb_asprintf_errstring(ldb, "cannot add allowedAttributes to %s because no schema is loaded", ldb_dn_get_linearized(msg->dn));
160 return LDB_ERR_OPERATIONS_ERROR;
163 /* Must remove any existing attribute */
164 if (ac->allowedAttributes) {
165 ldb_msg_remove_attr(msg, "allowedAttributes");
168 mem_ctx = talloc_new(msg);
173 oc_el = ldb_msg_find_element(sd_msg, "objectClass");
174 attr_list = dsdb_full_attribute_list(mem_ctx, schema, oc_el, DSDB_SCHEMA_ALL);
176 ldb_asprintf_errstring(ldb, "acl: Failed to get list of attributes");
177 talloc_free(mem_ctx);
178 return LDB_ERR_OPERATIONS_ERROR;
180 if (ac->allowedAttributes) {
181 for (i=0; attr_list && attr_list[i]; i++) {
182 ldb_msg_add_string(msg, "allowedAttributes", attr_list[i]);
185 if (ac->allowedAttributesEffective) {
186 struct security_descriptor *sd;
187 struct dom_sid *sid = NULL;
188 struct ldb_control *as_system = ldb_request_get_control(ac->req,
189 LDB_CONTROL_AS_SYSTEM_OID);
191 if (as_system != NULL) {
192 as_system->critical = 0;
195 ldb_msg_remove_attr(msg, "allowedAttributesEffective");
196 if (ac->am_system || as_system) {
197 for (i=0; attr_list && attr_list[i]; i++) {
198 ldb_msg_add_string(msg, "allowedAttributesEffective", attr_list[i]);
203 ret = dsdb_get_sd_from_ldb_message(ldb_module_get_ctx(module), mem_ctx, sd_msg, &sd);
205 if (ret != LDB_SUCCESS) {
209 sid = samdb_result_dom_sid(mem_ctx, sd_msg, "objectSid");
210 for (i=0; attr_list && attr_list[i]; i++) {
211 const struct dsdb_attribute *attr = dsdb_attribute_by_lDAPDisplayName(schema,
214 return ldb_operr(ldb);
216 /* remove constructed attributes */
217 if (attr->systemFlags & DS_FLAG_ATTR_IS_CONSTRUCTED
219 || (attr->linkID != 0 && attr->linkID % 2 != 0 )) {
222 ret = acl_check_access_on_attribute(module,
228 if (ret == LDB_SUCCESS) {
229 ldb_msg_add_string(msg, "allowedAttributesEffective", attr_list[i]);
236 static int acl_childClasses(struct ldb_module *module,
237 const struct dsdb_schema *schema,
238 struct ldb_message *sd_msg,
239 struct ldb_message *msg,
240 const char *attrName)
242 struct ldb_message_element *oc_el;
243 struct ldb_message_element *allowedClasses;
244 const struct dsdb_class *sclass;
248 /* If we don't have a schema yet, we can't do anything... */
249 if (schema == NULL) {
250 ldb_asprintf_errstring(ldb_module_get_ctx(module), "cannot add childClassesEffective to %s because no schema is loaded", ldb_dn_get_linearized(msg->dn));
251 return LDB_ERR_OPERATIONS_ERROR;
254 /* Must remove any existing attribute, or else confusion reins */
255 ldb_msg_remove_attr(msg, attrName);
256 ret = ldb_msg_add_empty(msg, attrName, 0, &allowedClasses);
257 if (ret != LDB_SUCCESS) {
261 oc_el = ldb_msg_find_element(sd_msg, "objectClass");
263 for (i=0; oc_el && i < oc_el->num_values; i++) {
264 sclass = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &oc_el->values[i]);
266 /* We don't know this class? what is going on? */
270 for (j=0; sclass->possibleInferiors && sclass->possibleInferiors[j]; j++) {
271 ldb_msg_add_string(msg, attrName, sclass->possibleInferiors[j]);
274 if (allowedClasses->num_values > 1) {
275 TYPESAFE_QSORT(allowedClasses->values, allowedClasses->num_values, data_blob_cmp);
276 for (i=1 ; i < allowedClasses->num_values; i++) {
277 struct ldb_val *val1 = &allowedClasses->values[i-1];
278 struct ldb_val *val2 = &allowedClasses->values[i];
279 if (data_blob_cmp(val1, val2) == 0) {
280 memmove(val1, val2, (allowedClasses->num_values - i) * sizeof(struct ldb_val));
281 allowedClasses->num_values--;
290 static int acl_childClassesEffective(struct ldb_module *module,
291 const struct dsdb_schema *schema,
292 struct ldb_message *sd_msg,
293 struct ldb_message *msg,
294 struct acl_context *ac)
296 struct ldb_message_element *oc_el;
297 struct ldb_message_element *allowedClasses = NULL;
298 const struct dsdb_class *sclass;
299 struct security_descriptor *sd;
300 struct ldb_control *as_system = ldb_request_get_control(ac->req,
301 LDB_CONTROL_AS_SYSTEM_OID);
302 struct dom_sid *sid = NULL;
306 if (as_system != NULL) {
307 as_system->critical = 0;
310 if (ac->am_system || as_system) {
311 return acl_childClasses(module, schema, sd_msg, msg, "allowedChildClassesEffective");
314 /* If we don't have a schema yet, we can't do anything... */
315 if (schema == NULL) {
316 ldb_asprintf_errstring(ldb_module_get_ctx(module), "cannot add allowedChildClassesEffective to %s because no schema is loaded", ldb_dn_get_linearized(msg->dn));
317 return LDB_ERR_OPERATIONS_ERROR;
320 /* Must remove any existing attribute, or else confusion reins */
321 ldb_msg_remove_attr(msg, "allowedChildClassesEffective");
323 oc_el = ldb_msg_find_element(sd_msg, "objectClass");
324 ret = dsdb_get_sd_from_ldb_message(ldb_module_get_ctx(module), msg, sd_msg, &sd);
325 if (ret != LDB_SUCCESS) {
329 sid = samdb_result_dom_sid(msg, sd_msg, "objectSid");
330 for (i=0; oc_el && i < oc_el->num_values; i++) {
331 sclass = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &oc_el->values[i]);
333 /* We don't know this class? what is going on? */
337 for (j=0; sclass->possibleInferiors && sclass->possibleInferiors[j]; j++) {
338 ret = acl_check_access_on_class(module,
343 SEC_ADS_CREATE_CHILD,
344 sclass->possibleInferiors[j]);
345 if (ret == LDB_SUCCESS) {
346 ldb_msg_add_string(msg, "allowedChildClassesEffective",
347 sclass->possibleInferiors[j]);
351 allowedClasses = ldb_msg_find_element(msg, "allowedChildClassesEffective");
352 if (!allowedClasses) {
356 if (allowedClasses->num_values > 1) {
357 TYPESAFE_QSORT(allowedClasses->values, allowedClasses->num_values, data_blob_cmp);
358 for (i=1 ; i < allowedClasses->num_values; i++) {
359 struct ldb_val *val1 = &allowedClasses->values[i-1];
360 struct ldb_val *val2 = &allowedClasses->values[i];
361 if (data_blob_cmp(val1, val2) == 0) {
362 memmove(val1, val2, (allowedClasses->num_values - i) * sizeof( struct ldb_val));
363 allowedClasses->num_values--;
371 static int acl_sDRightsEffective(struct ldb_module *module,
372 struct ldb_message *sd_msg,
373 struct ldb_message *msg,
374 struct acl_context *ac)
376 struct ldb_message_element *rightsEffective;
378 struct security_descriptor *sd;
379 struct ldb_control *as_system = ldb_request_get_control(ac->req,
380 LDB_CONTROL_AS_SYSTEM_OID);
381 struct dom_sid *sid = NULL;
384 if (as_system != NULL) {
385 as_system->critical = 0;
388 /* Must remove any existing attribute, or else confusion reins */
389 ldb_msg_remove_attr(msg, "sDRightsEffective");
390 ret = ldb_msg_add_empty(msg, "sDRightsEffective", 0, &rightsEffective);
391 if (ret != LDB_SUCCESS) {
394 if (ac->am_system || as_system) {
395 flags = SECINFO_OWNER | SECINFO_GROUP | SECINFO_SACL | SECINFO_DACL;
398 /* Get the security descriptor from the message */
399 ret = dsdb_get_sd_from_ldb_message(ldb_module_get_ctx(module), msg, sd_msg, &sd);
400 if (ret != LDB_SUCCESS) {
403 sid = samdb_result_dom_sid(msg, sd_msg, "objectSid");
404 ret = acl_check_access_on_attribute(module,
410 if (ret == LDB_SUCCESS) {
411 flags |= SECINFO_OWNER | SECINFO_GROUP;
413 ret = acl_check_access_on_attribute(module,
419 if (ret == LDB_SUCCESS) {
420 flags |= SECINFO_DACL;
422 ret = acl_check_access_on_attribute(module,
426 SEC_FLAG_SYSTEM_SECURITY,
428 if (ret == LDB_SUCCESS) {
429 flags |= SECINFO_SACL;
432 return samdb_msg_add_uint(ldb_module_get_ctx(module), msg, msg,
433 "sDRightsEffective", flags);
436 static int acl_validate_spn_value(TALLOC_CTX *mem_ctx,
437 struct ldb_context *ldb,
438 const char *spn_value,
439 uint32_t userAccountControl,
440 const char *samAccountName,
441 const char *dnsHostName,
442 const char *netbios_name,
443 const char *ntds_guid)
446 krb5_context krb_ctx;
447 krb5_error_code kerr;
448 krb5_principal principal;
453 const char *forest_name = samdb_forest_name(ldb, mem_ctx);
454 const char *base_domain = samdb_default_domain_name(ldb, mem_ctx);
455 struct loadparm_context *lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
456 struct loadparm_context);
457 bool is_dc = (userAccountControl & UF_SERVER_TRUST_ACCOUNT) ||
458 (userAccountControl & UF_PARTIAL_SECRETS_ACCOUNT);
460 if (strcasecmp_m(spn_value, samAccountName) == 0) {
461 /* MacOS X sets this value, and setting an SPN of your
462 * own samAccountName is both pointless and safe */
466 kerr = smb_krb5_init_context_basic(mem_ctx,
470 return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR,
471 "Could not initialize kerberos context.");
474 ret = krb5_parse_name(krb_ctx, spn_value, &principal);
476 krb5_free_context(krb_ctx);
477 return LDB_ERR_CONSTRAINT_VIOLATION;
480 if (principal->name.name_string.len < 2) {
484 instanceName = principal->name.name_string.val[1];
485 serviceType = principal->name.name_string.val[0];
486 realm = krb5_principal_get_realm(krb_ctx, principal);
487 if (principal->name.name_string.len == 3) {
488 serviceName = principal->name.name_string.val[2];
497 if (strcasecmp(serviceType, "ldap") == 0) {
498 if (strcasecmp(serviceName, netbios_name) != 0 &&
499 strcasecmp(serviceName, forest_name) != 0) {
503 } else if (strcasecmp(serviceType, "gc") == 0) {
504 if (strcasecmp(serviceName, forest_name) != 0) {
508 if (strcasecmp(serviceName, base_domain) != 0 &&
509 strcasecmp(serviceName, netbios_name) != 0) {
514 /* instanceName can be samAccountName without $ or dnsHostName
515 * or "ntds_guid._msdcs.forest_domain for DC objects */
516 if (strlen(instanceName) == (strlen(samAccountName) - 1)
517 && strncasecmp(instanceName, samAccountName, strlen(samAccountName) - 1) == 0) {
519 } else if (strcasecmp(instanceName, dnsHostName) == 0) {
522 const char *guid_str;
523 guid_str = talloc_asprintf(mem_ctx,"%s._msdcs.%s",
526 if (strcasecmp(instanceName, guid_str) == 0) {
532 krb5_free_principal(krb_ctx, principal);
533 krb5_free_context(krb_ctx);
534 return LDB_ERR_CONSTRAINT_VIOLATION;
537 krb5_free_principal(krb_ctx, principal);
538 krb5_free_context(krb_ctx);
542 static int acl_check_spn(TALLOC_CTX *mem_ctx,
543 struct ldb_module *module,
544 struct ldb_request *req,
545 struct security_descriptor *sd,
547 const struct GUID *oc_guid,
548 const struct dsdb_attribute *attr)
552 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
553 struct ldb_context *ldb = ldb_module_get_ctx(module);
554 struct ldb_result *acl_res;
555 struct ldb_result *netbios_res;
556 struct ldb_message_element *el;
557 struct ldb_dn *partitions_dn = samdb_partitions_dn(ldb, tmp_ctx);
558 uint32_t userAccountControl;
559 const char *samAccountName;
560 const char *dnsHostName;
561 const char *netbios_name;
563 char *ntds_guid = NULL;
565 static const char *acl_attrs[] = {
568 "userAccountControl",
571 static const char *netbios_attrs[] = {
576 /* if we have wp, we can do whatever we like */
577 if (acl_check_access_on_attribute(module,
582 attr) == LDB_SUCCESS) {
583 talloc_free(tmp_ctx);
587 ret = acl_check_extended_right(tmp_ctx, sd, acl_user_token(module),
588 GUID_DRS_VALIDATE_SPN,
592 if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
593 dsdb_acl_debug(sd, acl_user_token(module),
594 req->op.mod.message->dn,
597 talloc_free(tmp_ctx);
601 ret = dsdb_module_search_dn(module, tmp_ctx,
602 &acl_res, req->op.mod.message->dn,
604 DSDB_FLAG_NEXT_MODULE |
605 DSDB_SEARCH_SHOW_DELETED, req);
606 if (ret != LDB_SUCCESS) {
607 talloc_free(tmp_ctx);
611 userAccountControl = ldb_msg_find_attr_as_uint(acl_res->msgs[0], "userAccountControl", 0);
612 dnsHostName = ldb_msg_find_attr_as_string(acl_res->msgs[0], "dnsHostName", NULL);
613 samAccountName = ldb_msg_find_attr_as_string(acl_res->msgs[0], "samAccountName", NULL);
615 ret = dsdb_module_search(module, tmp_ctx,
616 &netbios_res, partitions_dn,
619 DSDB_FLAG_NEXT_MODULE,
622 ldb_dn_get_linearized(ldb_get_default_basedn(ldb)));
624 netbios_name = ldb_msg_find_attr_as_string(netbios_res->msgs[0], "nETBIOSName", NULL);
626 el = ldb_msg_find_element(req->op.mod.message, "servicePrincipalName");
628 talloc_free(tmp_ctx);
629 return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR,
630 "Error finding element for servicePrincipalName.");
633 /* NTDSDSA objectGuid of object we are checking SPN for */
634 if (userAccountControl & (UF_SERVER_TRUST_ACCOUNT | UF_PARTIAL_SECRETS_ACCOUNT)) {
635 ret = dsdb_module_find_ntdsguid_for_computer(module, tmp_ctx,
636 req->op.mod.message->dn, &ntds, req);
637 if (ret != LDB_SUCCESS) {
638 ldb_asprintf_errstring(ldb, "Failed to find NTDSDSA objectGuid for %s: %s",
639 ldb_dn_get_linearized(req->op.mod.message->dn),
641 talloc_free(tmp_ctx);
642 return LDB_ERR_OPERATIONS_ERROR;
644 ntds_guid = GUID_string(tmp_ctx, &ntds);
647 for (i=0; i < el->num_values; i++) {
648 ret = acl_validate_spn_value(tmp_ctx,
650 (char *)el->values[i].data,
656 if (ret != LDB_SUCCESS) {
657 talloc_free(tmp_ctx);
661 talloc_free(tmp_ctx);
665 static int acl_add(struct ldb_module *module, struct ldb_request *req)
668 struct ldb_dn *parent = ldb_dn_get_parent(req, req->op.add.message->dn);
669 struct ldb_context *ldb;
670 const struct dsdb_schema *schema;
671 struct ldb_message_element *oc_el;
672 const struct GUID *guid;
673 struct ldb_dn *nc_root;
674 struct ldb_control *as_system = ldb_request_get_control(req, LDB_CONTROL_AS_SYSTEM_OID);
676 if (as_system != NULL) {
677 as_system->critical = 0;
680 if (dsdb_module_am_system(module) || as_system) {
681 return ldb_next_request(module, req);
683 if (ldb_dn_is_special(req->op.add.message->dn)) {
684 return ldb_next_request(module, req);
687 ldb = ldb_module_get_ctx(module);
689 /* Creating an NC. There is probably something we should do here,
690 * but we will establish that later */
692 ret = dsdb_find_nc_root(ldb, req, req->op.add.message->dn, &nc_root);
693 if (ret != LDB_SUCCESS) {
696 if (ldb_dn_compare(nc_root, req->op.add.message->dn) == 0) {
697 talloc_free(nc_root);
698 return ldb_next_request(module, req);
700 talloc_free(nc_root);
702 schema = dsdb_get_schema(ldb, req);
704 return ldb_operr(ldb);
707 oc_el = ldb_msg_find_element(req->op.add.message, "objectClass");
708 if (!oc_el || oc_el->num_values == 0) {
709 ldb_asprintf_errstring(ldb_module_get_ctx(module),
710 "acl: unable to find objectClass on %s\n",
711 ldb_dn_get_linearized(req->op.add.message->dn));
712 return ldb_module_done(req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
715 guid = class_schemaid_guid_by_lDAPDisplayName(schema,
716 (char *)oc_el->values[oc_el->num_values-1].data);
717 ret = dsdb_module_check_access_on_dn(module, req, parent, SEC_ADS_CREATE_CHILD, guid, req);
718 if (ret != LDB_SUCCESS) {
721 return ldb_next_request(module, req);
724 /* ckecks if modifications are allowed on "Member" attribute */
725 static int acl_check_self_membership(TALLOC_CTX *mem_ctx,
726 struct ldb_module *module,
727 struct ldb_request *req,
728 struct security_descriptor *sd,
730 const struct GUID *oc_guid,
731 const struct dsdb_attribute *attr)
735 struct ldb_context *ldb = ldb_module_get_ctx(module);
736 struct ldb_dn *user_dn;
737 struct ldb_message_element *member_el;
738 /* if we have wp, we can do whatever we like */
739 if (acl_check_access_on_attribute(module,
744 attr) == LDB_SUCCESS) {
747 /* if we are adding/deleting ourselves, check for self membership */
748 ret = dsdb_find_dn_by_sid(ldb, mem_ctx,
749 &acl_user_token(module)->sids[PRIMARY_USER_SID_INDEX],
751 if (ret != LDB_SUCCESS) {
754 member_el = ldb_msg_find_element(req->op.mod.message, "member");
756 return ldb_operr(ldb);
758 /* user can only remove oneself */
759 if (member_el->num_values == 0) {
760 return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
762 for (i = 0; i < member_el->num_values; i++) {
763 if (strcasecmp((const char *)member_el->values[i].data,
764 ldb_dn_get_extended_linearized(mem_ctx, user_dn, 1)) != 0) {
765 return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
768 ret = acl_check_extended_right(mem_ctx, sd, acl_user_token(module),
769 GUID_DRS_SELF_MEMBERSHIP,
772 if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
773 dsdb_acl_debug(sd, acl_user_token(module),
774 req->op.mod.message->dn,
781 static int acl_check_password_rights(TALLOC_CTX *mem_ctx,
782 struct ldb_module *module,
783 struct ldb_request *req,
784 struct security_descriptor *sd,
786 const struct GUID *oc_guid,
789 int ret = LDB_SUCCESS;
790 unsigned int del_attr_cnt = 0, add_attr_cnt = 0, rep_attr_cnt = 0;
791 struct ldb_message_element *el;
792 struct ldb_message *msg;
793 const char *passwordAttrs[] = { "userPassword", "clearTextPassword",
794 "unicodePwd", "dBCSPwd", NULL }, **l;
795 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
797 msg = ldb_msg_copy_shallow(tmp_ctx, req->op.mod.message);
799 return ldb_module_oom(module);
801 for (l = passwordAttrs; *l != NULL; l++) {
802 if ((!userPassword) && (ldb_attr_cmp(*l, "userPassword") == 0)) {
806 while ((el = ldb_msg_find_element(msg, *l)) != NULL) {
807 if (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_DELETE) {
810 if (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_ADD) {
813 if (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_REPLACE) {
816 ldb_msg_remove_element(msg, el);
820 /* single deletes will be handled by the "password_hash" LDB module
821 * later in the stack, so we let it though here */
822 if ((del_attr_cnt > 0) && (add_attr_cnt == 0) && (rep_attr_cnt == 0)) {
823 talloc_free(tmp_ctx);
827 if (ldb_request_get_control(req,
828 DSDB_CONTROL_PASSWORD_CHANGE_OID) != NULL) {
829 /* The "DSDB_CONTROL_PASSWORD_CHANGE_OID" control means that we
830 * have a user password change and not a set as the message
831 * looks like. In it's value blob it contains the NT and/or LM
832 * hash of the old password specified by the user.
833 * This control is used by the SAMR and "kpasswd" password
834 * change mechanisms. */
835 ret = acl_check_extended_right(tmp_ctx, sd, acl_user_token(module),
836 GUID_DRS_USER_CHANGE_PASSWORD,
837 SEC_ADS_CONTROL_ACCESS,
840 else if (rep_attr_cnt > 0 || (add_attr_cnt != del_attr_cnt)) {
841 ret = acl_check_extended_right(tmp_ctx, sd, acl_user_token(module),
842 GUID_DRS_FORCE_CHANGE_PASSWORD,
843 SEC_ADS_CONTROL_ACCESS,
846 else if (add_attr_cnt == 1 && del_attr_cnt == 1) {
847 ret = acl_check_extended_right(tmp_ctx, sd, acl_user_token(module),
848 GUID_DRS_USER_CHANGE_PASSWORD,
849 SEC_ADS_CONTROL_ACCESS,
851 /* Very strange, but we get constraint violation in this case */
852 if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
853 ret = LDB_ERR_CONSTRAINT_VIOLATION;
856 if (ret != LDB_SUCCESS) {
857 dsdb_acl_debug(sd, acl_user_token(module),
858 req->op.mod.message->dn,
862 talloc_free(tmp_ctx);
866 static int acl_modify(struct ldb_module *module, struct ldb_request *req)
869 struct ldb_context *ldb = ldb_module_get_ctx(module);
870 const struct dsdb_schema *schema;
872 const struct GUID *guid;
873 uint32_t access_granted;
874 struct object_tree *root = NULL;
875 struct object_tree *new_node = NULL;
877 struct ldb_result *acl_res;
878 struct security_descriptor *sd;
879 struct dom_sid *sid = NULL;
880 struct ldb_control *as_system = ldb_request_get_control(req, LDB_CONTROL_AS_SYSTEM_OID);
881 bool userPassword = dsdb_user_password_support(module, req, req);
882 TALLOC_CTX *tmp_ctx = talloc_new(req);
883 static const char *acl_attrs[] = {
884 "nTSecurityDescriptor",
890 if (as_system != NULL) {
891 as_system->critical = 0;
894 /* Don't print this debug statement if elements[0].name is going to be NULL */
895 if(req->op.mod.message->num_elements > 0)
897 DEBUG(10, ("ldb:acl_modify: %s\n", req->op.mod.message->elements[0].name));
899 if (dsdb_module_am_system(module) || as_system) {
900 return ldb_next_request(module, req);
902 if (ldb_dn_is_special(req->op.mod.message->dn)) {
903 return ldb_next_request(module, req);
905 ret = dsdb_module_search_dn(module, tmp_ctx, &acl_res, req->op.mod.message->dn,
907 DSDB_FLAG_NEXT_MODULE | DSDB_SEARCH_SHOW_DELETED,
910 if (ret != LDB_SUCCESS) {
914 schema = dsdb_get_schema(ldb, tmp_ctx);
916 ret = LDB_ERR_OPERATIONS_ERROR;
920 ret = dsdb_get_sd_from_ldb_message(ldb, tmp_ctx, acl_res->msgs[0], &sd);
921 if (ret != LDB_SUCCESS) {
922 talloc_free(tmp_ctx);
923 return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR,
924 "acl_modify: Error retrieving security descriptor.");
926 /* Theoretically we pass the check if the object has no sd */
931 guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]);
933 talloc_free(tmp_ctx);
934 return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR,
935 "acl_modify: Error retrieving object class GUID.");
937 sid = samdb_result_dom_sid(req, acl_res->msgs[0], "objectSid");
938 if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP,
940 talloc_free(tmp_ctx);
941 return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR,
942 "acl_modify: Error adding new node in object tree.");
944 for (i=0; i < req->op.mod.message->num_elements; i++){
945 const struct dsdb_attribute *attr;
946 attr = dsdb_attribute_by_lDAPDisplayName(schema,
947 req->op.mod.message->elements[i].name);
949 if (ldb_attr_cmp("nTSecurityDescriptor", req->op.mod.message->elements[i].name) == 0) {
950 status = sec_access_check_ds(sd, acl_user_token(module),
956 if (!NT_STATUS_IS_OK(status)) {
957 ldb_asprintf_errstring(ldb_module_get_ctx(module),
958 "Object %s has no write dacl access\n",
959 ldb_dn_get_linearized(req->op.mod.message->dn));
961 acl_user_token(module),
962 req->op.mod.message->dn,
965 ret = LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
969 else if (ldb_attr_cmp("member", req->op.mod.message->elements[i].name) == 0) {
970 ret = acl_check_self_membership(tmp_ctx,
977 if (ret != LDB_SUCCESS) {
981 else if (ldb_attr_cmp("dBCSPwd", req->op.mod.message->elements[i].name) == 0) {
982 /* this one is not affected by any rights, we should let it through
983 so that passwords_hash returns the correct error */
986 else if (ldb_attr_cmp("unicodePwd", req->op.mod.message->elements[i].name) == 0 ||
987 (userPassword && ldb_attr_cmp("userPassword", req->op.mod.message->elements[i].name) == 0) ||
988 ldb_attr_cmp("clearTextPassword", req->op.mod.message->elements[i].name) == 0) {
989 ret = acl_check_password_rights(tmp_ctx,
996 if (ret != LDB_SUCCESS) {
999 } else if (ldb_attr_cmp("servicePrincipalName", req->op.mod.message->elements[i].name) == 0) {
1000 ret = acl_check_spn(tmp_ctx,
1007 if (ret != LDB_SUCCESS) {
1012 /* This basic attribute existence check with the right errorcode
1013 * is needed since this module is the first one which requests
1014 * schema attribute information.
1015 * The complete attribute checking is done in the
1016 * "objectclass_attrs" module behind this one.
1019 ldb_asprintf_errstring(ldb, "acl_modify: attribute '%s' on entry '%s' was not found in the schema!",
1020 req->op.mod.message->elements[i].name,
1021 ldb_dn_get_linearized(req->op.mod.message->dn));
1022 ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
1025 if (!insert_in_object_tree(tmp_ctx,
1026 &attr->attributeSecurityGUID, SEC_ADS_WRITE_PROP,
1027 &new_node, &new_node)) {
1028 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1029 "acl_modify: cannot add to object tree securityGUID\n");
1030 ret = LDB_ERR_OPERATIONS_ERROR;
1034 if (!insert_in_object_tree(tmp_ctx,
1035 &attr->schemaIDGUID, SEC_ADS_WRITE_PROP, &new_node, &new_node)) {
1036 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1037 "acl_modify: cannot add to object tree attributeGUID\n");
1038 ret = LDB_ERR_OPERATIONS_ERROR;
1044 if (root->num_of_children > 0) {
1045 status = sec_access_check_ds(sd, acl_user_token(module),
1051 if (!NT_STATUS_IS_OK(status)) {
1052 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1053 "Object %s has no write property access\n",
1054 ldb_dn_get_linearized(req->op.mod.message->dn));
1056 acl_user_token(module),
1057 req->op.mod.message->dn,
1060 ret = LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
1066 talloc_free(tmp_ctx);
1067 return ldb_next_request(module, req);
1069 talloc_free(tmp_ctx);
1073 /* similar to the modify for the time being.
1074 * We need to consider the special delete tree case, though - TODO */
1075 static int acl_delete(struct ldb_module *module, struct ldb_request *req)
1078 struct ldb_dn *parent = ldb_dn_get_parent(req, req->op.del.dn);
1079 struct ldb_context *ldb;
1080 struct ldb_dn *nc_root;
1081 struct ldb_control *as_system = ldb_request_get_control(req, LDB_CONTROL_AS_SYSTEM_OID);
1083 if (as_system != NULL) {
1084 as_system->critical = 0;
1087 DEBUG(10, ("ldb:acl_delete: %s\n", ldb_dn_get_linearized(req->op.del.dn)));
1088 if (dsdb_module_am_system(module) || as_system) {
1089 return ldb_next_request(module, req);
1091 if (ldb_dn_is_special(req->op.del.dn)) {
1092 return ldb_next_request(module, req);
1095 ldb = ldb_module_get_ctx(module);
1097 /* Make sure we aren't deleting a NC */
1099 ret = dsdb_find_nc_root(ldb, req, req->op.del.dn, &nc_root);
1100 if (ret != LDB_SUCCESS) {
1103 if (ldb_dn_compare(nc_root, req->op.del.dn) == 0) {
1104 talloc_free(nc_root);
1105 DEBUG(10,("acl:deleting a NC\n"));
1106 /* Windows returns "ERR_UNWILLING_TO_PERFORM */
1107 return ldb_module_done(req, NULL, NULL,
1108 LDB_ERR_UNWILLING_TO_PERFORM);
1110 talloc_free(nc_root);
1112 /* First check if we have delete object right */
1113 ret = dsdb_module_check_access_on_dn(module, req, req->op.del.dn,
1114 SEC_STD_DELETE, NULL, req);
1115 if (ret == LDB_SUCCESS) {
1116 return ldb_next_request(module, req);
1119 /* Nope, we don't have delete object. Lets check if we have delete
1120 * child on the parent */
1121 ret = dsdb_module_check_access_on_dn(module, req, parent,
1122 SEC_ADS_DELETE_CHILD, NULL, req);
1123 if (ret != LDB_SUCCESS) {
1127 return ldb_next_request(module, req);
1130 static int acl_rename(struct ldb_module *module, struct ldb_request *req)
1133 struct ldb_dn *oldparent = ldb_dn_get_parent(req, req->op.rename.olddn);
1134 struct ldb_dn *newparent = ldb_dn_get_parent(req, req->op.rename.newdn);
1135 const struct dsdb_schema *schema;
1136 struct ldb_context *ldb;
1137 struct security_descriptor *sd = NULL;
1138 struct dom_sid *sid = NULL;
1139 struct ldb_result *acl_res;
1140 const struct GUID *guid;
1141 struct ldb_dn *nc_root;
1142 struct object_tree *root = NULL;
1143 struct object_tree *new_node = NULL;
1144 struct ldb_control *as_system = ldb_request_get_control(req, LDB_CONTROL_AS_SYSTEM_OID);
1145 TALLOC_CTX *tmp_ctx = talloc_new(req);
1147 uint32_t access_granted;
1148 const char *rdn_name;
1149 static const char *acl_attrs[] = {
1150 "nTSecurityDescriptor",
1156 if (as_system != NULL) {
1157 as_system->critical = 0;
1160 DEBUG(10, ("ldb:acl_rename: %s\n", ldb_dn_get_linearized(req->op.rename.olddn)));
1161 if (dsdb_module_am_system(module) || as_system) {
1162 return ldb_next_request(module, req);
1164 if (ldb_dn_is_special(req->op.rename.olddn)) {
1165 return ldb_next_request(module, req);
1168 ldb = ldb_module_get_ctx(module);
1170 /* Make sure we aren't renaming/moving a NC */
1172 ret = dsdb_find_nc_root(ldb, req, req->op.rename.olddn, &nc_root);
1173 if (ret != LDB_SUCCESS) {
1176 if (ldb_dn_compare(nc_root, req->op.rename.olddn) == 0) {
1177 talloc_free(nc_root);
1178 DEBUG(10,("acl:renaming/moving a NC\n"));
1179 /* Windows returns "ERR_UNWILLING_TO_PERFORM */
1180 return ldb_module_done(req, NULL, NULL,
1181 LDB_ERR_UNWILLING_TO_PERFORM);
1183 talloc_free(nc_root);
1185 /* Look for the parent */
1187 ret = dsdb_module_search_dn(module, tmp_ctx, &acl_res,
1188 req->op.rename.olddn, acl_attrs,
1189 DSDB_FLAG_NEXT_MODULE |
1190 DSDB_SEARCH_SHOW_RECYCLED, req);
1191 /* we sould be able to find the parent */
1192 if (ret != LDB_SUCCESS) {
1193 DEBUG(10,("acl: failed to find object %s\n",
1194 ldb_dn_get_linearized(req->op.rename.olddn)));
1195 talloc_free(tmp_ctx);
1199 schema = dsdb_get_schema(ldb, acl_res);
1201 talloc_free(tmp_ctx);
1202 return ldb_operr(ldb);
1205 guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]);
1206 if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP,
1207 &root, &new_node)) {
1208 talloc_free(tmp_ctx);
1209 return ldb_operr(ldb);
1212 guid = attribute_schemaid_guid_by_lDAPDisplayName(schema,
1214 if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP,
1215 &new_node, &new_node)) {
1216 talloc_free(tmp_ctx);
1217 return ldb_operr(ldb);
1220 rdn_name = ldb_dn_get_rdn_name(req->op.rename.olddn);
1221 if (rdn_name == NULL) {
1222 talloc_free(tmp_ctx);
1223 return ldb_operr(ldb);
1225 guid = attribute_schemaid_guid_by_lDAPDisplayName(schema,
1227 if (!insert_in_object_tree(tmp_ctx, guid, SEC_ADS_WRITE_PROP,
1228 &new_node, &new_node)) {
1229 talloc_free(tmp_ctx);
1230 return ldb_operr(ldb);
1233 ret = dsdb_get_sd_from_ldb_message(ldb, req, acl_res->msgs[0], &sd);
1235 if (ret != LDB_SUCCESS) {
1236 talloc_free(tmp_ctx);
1237 return ldb_operr(ldb);
1239 /* Theoretically we pass the check if the object has no sd */
1241 talloc_free(tmp_ctx);
1244 sid = samdb_result_dom_sid(req, acl_res->msgs[0], "objectSid");
1245 status = sec_access_check_ds(sd, acl_user_token(module),
1251 if (!NT_STATUS_IS_OK(status)) {
1252 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1253 "Object %s has no wp on name\n",
1254 ldb_dn_get_linearized(req->op.rename.olddn));
1256 acl_user_token(module),
1257 req->op.rename.olddn,
1260 talloc_free(tmp_ctx);
1261 return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
1264 if (ldb_dn_compare(oldparent, newparent) == 0) {
1265 /* regular rename, not move, nothing more to do */
1266 talloc_free(tmp_ctx);
1267 return ldb_next_request(module, req);
1270 /* new parent should have create child */
1273 guid = get_oc_guid_from_message(module, schema, acl_res->msgs[0]);
1275 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1276 "acl:renamed object has no object class\n");
1277 talloc_free(tmp_ctx);
1278 return ldb_module_done(req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
1281 ret = dsdb_module_check_access_on_dn(module, req, newparent, SEC_ADS_CREATE_CHILD, guid, req);
1282 if (ret != LDB_SUCCESS) {
1283 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1284 "acl:access_denied renaming %s",
1285 ldb_dn_get_linearized(req->op.rename.olddn));
1286 talloc_free(tmp_ctx);
1289 /* do we have delete object on the object? */
1291 status = sec_access_check_ds(sd, acl_user_token(module),
1297 if (NT_STATUS_IS_OK(status)) {
1298 talloc_free(tmp_ctx);
1299 return ldb_next_request(module, req);
1301 /* what about delete child on the current parent */
1302 ret = dsdb_module_check_access_on_dn(module, req, oldparent, SEC_ADS_DELETE_CHILD, NULL, req);
1303 if (ret != LDB_SUCCESS) {
1304 ldb_asprintf_errstring(ldb_module_get_ctx(module),
1305 "acl:access_denied renaming %s", ldb_dn_get_linearized(req->op.rename.olddn));
1306 talloc_free(tmp_ctx);
1307 return ldb_module_done(req, NULL, NULL, ret);
1310 talloc_free(tmp_ctx);
1312 return ldb_next_request(module, req);
1315 static int acl_search_callback(struct ldb_request *req, struct ldb_reply *ares)
1317 struct ldb_context *ldb;
1318 struct acl_context *ac;
1319 struct acl_private *data;
1320 struct ldb_result *acl_res;
1321 static const char *acl_attrs[] = {
1323 "nTSecurityDescriptor",
1330 ac = talloc_get_type(req->context, struct acl_context);
1331 data = talloc_get_type(ldb_module_get_private(ac->module), struct acl_private);
1332 ldb = ldb_module_get_ctx(ac->module);
1335 return ldb_module_done(ac->req, NULL, NULL,
1336 LDB_ERR_OPERATIONS_ERROR);
1338 if (ares->error != LDB_SUCCESS) {
1339 return ldb_module_done(ac->req, ares->controls,
1340 ares->response, ares->error);
1343 switch (ares->type) {
1344 case LDB_REPLY_ENTRY:
1345 if (ac->allowedAttributes
1346 || ac->allowedChildClasses
1347 || ac->allowedChildClassesEffective
1348 || ac->allowedAttributesEffective
1349 || ac->sDRightsEffective) {
1350 ret = dsdb_module_search_dn(ac->module, ac, &acl_res, ares->message->dn,
1352 DSDB_FLAG_NEXT_MODULE |
1353 DSDB_SEARCH_SHOW_DELETED, req);
1354 if (ret != LDB_SUCCESS) {
1355 return ldb_module_done(ac->req, NULL, NULL, ret);
1357 if (ac->allowedAttributes || ac->allowedAttributesEffective) {
1358 ret = acl_allowedAttributes(ac->module, ac->schema, acl_res->msgs[0], ares->message, ac);
1359 if (ret != LDB_SUCCESS) {
1360 return ldb_module_done(ac->req, NULL, NULL, ret);
1363 if (ac->allowedChildClasses) {
1364 ret = acl_childClasses(ac->module, ac->schema, acl_res->msgs[0],
1365 ares->message, "allowedChildClasses");
1366 if (ret != LDB_SUCCESS) {
1367 return ldb_module_done(ac->req, NULL, NULL, ret);
1370 if (ac->allowedChildClassesEffective) {
1371 ret = acl_childClassesEffective(ac->module, ac->schema,
1372 acl_res->msgs[0], ares->message, ac);
1373 if (ret != LDB_SUCCESS) {
1374 return ldb_module_done(ac->req, NULL, NULL, ret);
1377 if (ac->sDRightsEffective) {
1378 ret = acl_sDRightsEffective(ac->module,
1379 acl_res->msgs[0], ares->message, ac);
1380 if (ret != LDB_SUCCESS) {
1381 return ldb_module_done(ac->req, NULL, NULL, ret);
1385 if (data && data->password_attrs) {
1386 if (!ac->am_system) {
1387 for (i = 0; data->password_attrs[i]; i++) {
1388 if ((!ac->userPassword) &&
1389 (ldb_attr_cmp(data->password_attrs[i],
1390 "userPassword") == 0))
1393 ldb_msg_remove_attr(ares->message, data->password_attrs[i]);
1397 return ldb_module_send_entry(ac->req, ares->message, ares->controls);
1399 case LDB_REPLY_REFERRAL:
1400 return ldb_module_send_referral(ac->req, ares->referral);
1402 case LDB_REPLY_DONE:
1403 return ldb_module_done(ac->req, ares->controls,
1404 ares->response, LDB_SUCCESS);
1410 static int acl_search(struct ldb_module *module, struct ldb_request *req)
1412 struct ldb_context *ldb;
1413 struct acl_context *ac;
1414 struct ldb_request *down_req;
1415 struct acl_private *data;
1419 ldb = ldb_module_get_ctx(module);
1421 ac = talloc_zero(req, struct acl_context);
1423 return ldb_oom(ldb);
1425 data = talloc_get_type(ldb_module_get_private(module), struct acl_private);
1427 ac->module = module;
1429 ac->am_system = dsdb_module_am_system(module);
1430 ac->allowedAttributes = ldb_attr_in_list(req->op.search.attrs, "allowedAttributes");
1431 ac->allowedAttributesEffective = ldb_attr_in_list(req->op.search.attrs, "allowedAttributesEffective");
1432 ac->allowedChildClasses = ldb_attr_in_list(req->op.search.attrs, "allowedChildClasses");
1433 ac->allowedChildClassesEffective = ldb_attr_in_list(req->op.search.attrs, "allowedChildClassesEffective");
1434 ac->sDRightsEffective = ldb_attr_in_list(req->op.search.attrs, "sDRightsEffective");
1435 ac->userPassword = dsdb_user_password_support(module, ac, req);
1436 ac->schema = dsdb_get_schema(ldb, ac);
1438 /* replace any attributes in the parse tree that are private,
1439 so we don't allow a search for 'userPassword=penguin',
1440 just as we would not allow that attribute to be returned */
1441 if (ac->am_system) {
1442 /* FIXME: We should copy the tree and keep the original unmodified. */
1443 /* remove password attributes */
1444 if (data && data->password_attrs) {
1445 for (i = 0; data->password_attrs[i]; i++) {
1446 if ((!ac->userPassword) &&
1447 (ldb_attr_cmp(data->password_attrs[i],
1448 "userPassword") == 0))
1451 ldb_parse_tree_attr_replace(req->op.search.tree,
1452 data->password_attrs[i],
1453 "kludgeACLredactedattribute");
1457 ret = ldb_build_search_req_ex(&down_req,
1459 req->op.search.base,
1460 req->op.search.scope,
1461 req->op.search.tree,
1462 req->op.search.attrs,
1464 ac, acl_search_callback,
1466 LDB_REQ_SET_LOCATION(down_req);
1467 if (ret != LDB_SUCCESS) {
1470 /* perform the search */
1471 return ldb_next_request(module, down_req);
1474 static int acl_extended(struct ldb_module *module, struct ldb_request *req)
1476 struct ldb_context *ldb = ldb_module_get_ctx(module);
1477 struct ldb_control *as_system = ldb_request_get_control(req, LDB_CONTROL_AS_SYSTEM_OID);
1479 /* allow everybody to read the sequence number */
1480 if (strcmp(req->op.extended.oid,
1481 LDB_EXTENDED_SEQUENCE_NUMBER) == 0) {
1482 return ldb_next_request(module, req);
1485 if (dsdb_module_am_system(module) ||
1486 dsdb_module_am_administrator(module) || as_system) {
1487 return ldb_next_request(module, req);
1489 ldb_asprintf_errstring(ldb,
1491 "attempted database modify not permitted. "
1492 "User %s is not SYSTEM or an administrator",
1493 acl_user_name(req, module));
1494 return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
1498 static const struct ldb_module_ops ldb_acl_module_ops = {
1500 .search = acl_search,
1502 .modify = acl_modify,
1504 .rename = acl_rename,
1505 .extended = acl_extended,
1506 .init_context = acl_module_init
1509 int ldb_acl_module_init(const char *version)
1511 LDB_MODULE_CHECK_VERSION(version);
1512 return ldb_register_module(&ldb_acl_module_ops);