4 Copyright (C) Simo Sorce 2006-2008
5 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005-2009
6 Copyright (C) Stefan Metzmacher 2009
7 Copyright (C) Matthias Dieter Wallnöfer 2010
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, see <http://www.gnu.org/licenses/>.
26 * Component: objectclass attribute checking module
28 * Description: this checks the attributes on a directory entry (if they're
29 * allowed, if the syntax is correct, if mandatory ones are missing,
30 * denies the deletion of mandatory ones...). The module contains portions
31 * of the "objectclass" and the "validate_update" LDB module.
33 * Author: Matthias Dieter Wallnöfer
37 #include "ldb_module.h"
38 #include "dsdb/samdb/samdb.h"
39 #include "dsdb/samdb/ldb_modules/util.h"
43 struct ldb_module
*module
;
44 struct ldb_request
*req
;
45 const struct dsdb_schema
*schema
;
47 struct ldb_message
*msg
;
49 struct ldb_reply
*search_res
;
50 struct ldb_reply
*mod_ares
;
53 static struct oc_context
*oc_init_context(struct ldb_module
*module
,
54 struct ldb_request
*req
)
56 struct ldb_context
*ldb
;
57 struct oc_context
*ac
;
59 ldb
= ldb_module_get_ctx(module
);
61 ac
= talloc_zero(req
, struct oc_context
);
69 ac
->schema
= dsdb_get_schema(ldb
, ac
);
74 static int oc_op_callback(struct ldb_request
*req
, struct ldb_reply
*ares
);
77 * Checks the correctness of the "dSHeuristics" attribute as described in both
78 * MS-ADTS 7.1.1.2.4.1.2 dSHeuristics and MS-ADTS 3.1.1.5.3.2 Constraints
80 static int oc_validate_dsheuristics(struct ldb_message_element
*el
)
82 if (el
->num_values
> 0) {
83 if ((el
->values
[0].length
>= DS_HR_NINETIETH_CHAR
) &&
84 (el
->values
[0].data
[DS_HR_NINETIETH_CHAR
-1] != '9')) {
85 return LDB_ERR_CONSTRAINT_VIOLATION
;
87 if ((el
->values
[0].length
>= DS_HR_EIGHTIETH_CHAR
) &&
88 (el
->values
[0].data
[DS_HR_EIGHTIETH_CHAR
-1] != '8')) {
89 return LDB_ERR_CONSTRAINT_VIOLATION
;
91 if ((el
->values
[0].length
>= DS_HR_SEVENTIETH_CHAR
) &&
92 (el
->values
[0].data
[DS_HR_SEVENTIETH_CHAR
-1] != '7')) {
93 return LDB_ERR_CONSTRAINT_VIOLATION
;
95 if ((el
->values
[0].length
>= DS_HR_SIXTIETH_CHAR
) &&
96 (el
->values
[0].data
[DS_HR_SIXTIETH_CHAR
-1] != '6')) {
97 return LDB_ERR_CONSTRAINT_VIOLATION
;
99 if ((el
->values
[0].length
>= DS_HR_FIFTIETH_CHAR
) &&
100 (el
->values
[0].data
[DS_HR_FIFTIETH_CHAR
-1] != '5')) {
101 return LDB_ERR_CONSTRAINT_VIOLATION
;
103 if ((el
->values
[0].length
>= DS_HR_FOURTIETH_CHAR
) &&
104 (el
->values
[0].data
[DS_HR_FOURTIETH_CHAR
-1] != '4')) {
105 return LDB_ERR_CONSTRAINT_VIOLATION
;
107 if ((el
->values
[0].length
>= DS_HR_THIRTIETH_CHAR
) &&
108 (el
->values
[0].data
[DS_HR_THIRTIETH_CHAR
-1] != '3')) {
109 return LDB_ERR_CONSTRAINT_VIOLATION
;
111 if ((el
->values
[0].length
>= DS_HR_TWENTIETH_CHAR
) &&
112 (el
->values
[0].data
[DS_HR_TWENTIETH_CHAR
-1] != '2')) {
113 return LDB_ERR_CONSTRAINT_VIOLATION
;
115 if ((el
->values
[0].length
>= DS_HR_TENTH_CHAR
) &&
116 (el
->values
[0].data
[DS_HR_TENTH_CHAR
-1] != '1')) {
117 return LDB_ERR_CONSTRAINT_VIOLATION
;
125 auto normalise values on input
127 static int oc_auto_normalise(struct ldb_context
*ldb
, const struct dsdb_attribute
*attr
,
128 struct ldb_message
*msg
, struct ldb_message_element
*el
)
131 bool values_copied
= false;
133 for (i
=0; i
<el
->num_values
; i
++) {
136 ret
= attr
->ldb_schema_attribute
->syntax
->canonicalise_fn(ldb
, el
->values
, &el
->values
[i
], &v
);
137 if (ret
!= LDB_SUCCESS
) {
140 if (data_blob_cmp(&v
, &el
->values
[i
]) == 0) {
141 /* no need to replace it */
146 /* we need to copy the values array on the first change */
147 if (!values_copied
) {
149 v2
= talloc_array(msg
->elements
, struct ldb_val
, el
->num_values
);
153 memcpy(v2
, el
->values
, sizeof(struct ldb_val
) * el
->num_values
);
155 values_copied
= true;
163 static int attr_handler(struct oc_context
*ac
)
165 struct ldb_context
*ldb
;
166 struct ldb_message
*msg
;
167 struct ldb_request
*child_req
;
168 const struct dsdb_attribute
*attr
;
172 struct dsdb_syntax_ctx syntax_ctx
;
174 ldb
= ldb_module_get_ctx(ac
->module
);
176 if (ac
->req
->operation
== LDB_ADD
) {
177 msg
= ldb_msg_copy_shallow(ac
, ac
->req
->op
.add
.message
);
179 msg
= ldb_msg_copy_shallow(ac
, ac
->req
->op
.mod
.message
);
186 /* initialize syntax checking context */
187 dsdb_syntax_ctx_init(&syntax_ctx
, ldb
, ac
->schema
);
189 /* Check if attributes exist in the schema, if the values match,
190 * if they're not operational and fix the names to the match the schema
192 for (i
= 0; i
< msg
->num_elements
; i
++) {
193 attr
= dsdb_attribute_by_lDAPDisplayName(ac
->schema
,
194 msg
->elements
[i
].name
);
196 if (ldb_request_get_control(ac
->req
, DSDB_CONTROL_DBCHECK
) &&
197 ac
->req
->operation
!= LDB_ADD
) {
198 /* we allow this for dbcheck to fix
202 ldb_asprintf_errstring(ldb
, "objectclass_attrs: attribute '%s' on entry '%s' was not found in the schema!",
203 msg
->elements
[i
].name
,
204 ldb_dn_get_linearized(msg
->dn
));
205 return LDB_ERR_NO_SUCH_ATTRIBUTE
;
208 if ((attr
->linkID
& 1) == 1 &&
209 !ldb_request_get_control(ac
->req
, LDB_CONTROL_RELAX_OID
) &&
210 !ldb_request_get_control(ac
->req
, DSDB_CONTROL_DBCHECK
)) {
211 /* Odd is for the target. Illegal to modify */
212 ldb_asprintf_errstring(ldb
,
213 "objectclass_attrs: attribute '%s' on entry '%s' must not be modified directly, it is a linked attribute",
214 msg
->elements
[i
].name
,
215 ldb_dn_get_linearized(msg
->dn
));
216 return LDB_ERR_UNWILLING_TO_PERFORM
;
220 * Enforce systemOnly checks from [ADTS] 3.1.1.5.3.2
221 * Constraints in Modify Operation
223 if (ac
->req
->operation
== LDB_MODIFY
&& attr
->systemOnly
) {
225 * Allow dbcheck and relax to bypass. objectClass, name
226 * and distinguishedName are generally handled
229 * The remaining cases, undelete, msDS-AdditionalDnsHostName
230 * and wellKnownObjects are documented in the specification.
232 if (!ldb_request_get_control(ac
->req
, LDB_CONTROL_RELAX_OID
) &&
233 !ldb_request_get_control(ac
->req
, DSDB_CONTROL_DBCHECK
) &&
234 !ldb_request_get_control(ac
->req
, DSDB_CONTROL_RESTORE_TOMBSTONE_OID
) &&
235 ldb_attr_cmp(attr
->lDAPDisplayName
, "objectClass") != 0 &&
236 ldb_attr_cmp(attr
->lDAPDisplayName
, "name") != 0 &&
237 ldb_attr_cmp(attr
->lDAPDisplayName
, "distinguishedName") != 0 &&
238 ldb_attr_cmp(attr
->lDAPDisplayName
, "msDS-AdditionalDnsHostName") != 0 &&
239 ldb_attr_cmp(attr
->lDAPDisplayName
, "wellKnownObjects") != 0) {
241 * Comparison against base schema DN is used as a substitute for
242 * fschemaUpgradeInProgress and other specific schema checks.
244 if (ldb_dn_compare_base(ldb_get_schema_basedn(ldb
), msg
->dn
) != 0) {
245 struct ldb_control
*as_system
= ldb_request_get_control(ac
->req
,
246 LDB_CONTROL_AS_SYSTEM_OID
);
247 if (!dsdb_module_am_system(ac
->module
) && !as_system
) {
248 ldb_asprintf_errstring(ldb
,
249 "objectclass_attrs: attribute '%s' on entry '%s' must can only be modified as system",
250 msg
->elements
[i
].name
,
251 ldb_dn_get_linearized(msg
->dn
));
252 return LDB_ERR_CONSTRAINT_VIOLATION
;
258 if (!(msg
->elements
[i
].flags
& LDB_FLAG_INTERNAL_DISABLE_VALIDATION
)) {
259 werr
= attr
->syntax
->validate_ldb(&syntax_ctx
, attr
,
261 if (!W_ERROR_IS_OK(werr
) &&
262 !ldb_request_get_control(ac
->req
, DSDB_CONTROL_DBCHECK
)) {
263 ldb_asprintf_errstring(ldb
, "objectclass_attrs: attribute '%s' on entry '%s' contains at least one invalid value!",
264 msg
->elements
[i
].name
,
265 ldb_dn_get_linearized(msg
->dn
));
266 return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX
;
270 if ((attr
->systemFlags
& DS_FLAG_ATTR_IS_CONSTRUCTED
) != 0) {
271 ldb_asprintf_errstring(ldb
, "objectclass_attrs: attribute '%s' on entry '%s' is constructed!",
272 msg
->elements
[i
].name
,
273 ldb_dn_get_linearized(msg
->dn
));
274 if (ac
->req
->operation
== LDB_ADD
) {
275 return LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE
;
277 return LDB_ERR_CONSTRAINT_VIOLATION
;
281 /* "dSHeuristics" syntax check */
282 if (ldb_attr_cmp(attr
->lDAPDisplayName
, "dSHeuristics") == 0) {
283 ret
= oc_validate_dsheuristics(&(msg
->elements
[i
]));
284 if (ret
!= LDB_SUCCESS
) {
289 /* auto normalise some attribute values */
290 if (attr
->syntax
->auto_normalise
) {
291 ret
= oc_auto_normalise(ldb
, attr
, msg
, &msg
->elements
[i
]);
292 if (ret
!= LDB_SUCCESS
) {
297 /* Substitute the attribute name to match in case */
298 msg
->elements
[i
].name
= attr
->lDAPDisplayName
;
302 if (ac
->req
->operation
== LDB_ADD
) {
303 ret
= ldb_build_add_req(&child_req
, ldb
, ac
,
304 msg
, ac
->req
->controls
,
305 ac
, oc_op_callback
, ac
->req
);
306 LDB_REQ_SET_LOCATION(child_req
);
308 ret
= ldb_build_mod_req(&child_req
, ldb
, ac
,
309 msg
, ac
->req
->controls
,
310 ac
, oc_op_callback
, ac
->req
);
311 LDB_REQ_SET_LOCATION(child_req
);
313 if (ret
!= LDB_SUCCESS
) {
317 return ldb_next_request(ac
->module
, child_req
);
321 these are attributes which are left over from old ways of doing
322 things in ldb, and are harmless
324 static const char *harmless_attrs
[] = { "parentGUID", NULL
};
326 static int attr_handler2(struct oc_context
*ac
)
328 struct ldb_context
*ldb
;
329 struct ldb_message_element
*oc_element
;
330 struct ldb_message
*msg
;
331 const char **must_contain
, **may_contain
, **found_must_contain
;
332 /* There exists a hardcoded delete-protected attributes list in AD */
333 const char *del_prot_attributes
[] = { "nTSecurityDescriptor",
334 "objectSid", "sAMAccountType", "sAMAccountName", "groupType",
335 "primaryGroupID", "userAccountControl", "accountExpires",
336 "badPasswordTime", "badPwdCount", "codePage", "countryCode",
337 "lastLogoff", "lastLogon", "logonCount", "pwdLastSet", NULL
},
339 const struct dsdb_attribute
*attr
;
342 bool isSchemaAttr
= false;
344 ldb
= ldb_module_get_ctx(ac
->module
);
346 if (ac
->search_res
== NULL
) {
347 return ldb_operr(ldb
);
350 /* We rely here on the preceeding "objectclass" LDB module which did
351 * already fix up the objectclass list (inheritance, order...). */
352 oc_element
= ldb_msg_find_element(ac
->search_res
->message
,
354 if (oc_element
== NULL
) {
355 return ldb_operr(ldb
);
358 /* LSA-specific object classes are not allowed to be created over LDAP,
359 * so we need to tell if this connection is internal (trusted) or not
362 * Hongwei Sun from Microsoft explains:
363 * The constraint in 3.1.1.5.2.2 MS-ADTS means that LSA objects cannot
364 * be added or modified through the LDAP interface, instead they can
365 * only be handled through LSA Policy API. This is also explained in
366 * 7.1.6.9.7 MS-ADTS as follows:
367 * "Despite being replicated normally between peer DCs in a domain,
368 * the process of creating or manipulating TDOs is specifically
369 * restricted to the LSA Policy APIs, as detailed in [MS-LSAD] section
370 * 3.1.1.5. Unlike other objects in the DS, TDOs may not be created or
371 * manipulated by client machines over the LDAPv3 transport."
373 for (i
= 0; i
< oc_element
->num_values
; i
++) {
374 char * attname
= (char *)oc_element
->values
[i
].data
;
375 if (ldb_req_is_untrusted(ac
->req
)) {
376 if (strcmp(attname
, "secret") == 0 ||
377 strcmp(attname
, "trustedDomain") == 0) {
378 ldb_asprintf_errstring(ldb
, "objectclass_attrs: LSA objectclasses (entry '%s') cannot be created or changed over LDAP!",
379 ldb_dn_get_linearized(ac
->search_res
->message
->dn
));
380 return LDB_ERR_UNWILLING_TO_PERFORM
;
383 if (strcmp(attname
, "attributeSchema") == 0) {
388 must_contain
= dsdb_full_attribute_list(ac
, ac
->schema
, oc_element
,
389 DSDB_SCHEMA_ALL_MUST
);
390 may_contain
= dsdb_full_attribute_list(ac
, ac
->schema
, oc_element
,
391 DSDB_SCHEMA_ALL_MAY
);
392 found_must_contain
= const_str_list(str_list_copy(ac
, must_contain
));
393 if ((must_contain
== NULL
) || (may_contain
== NULL
)
394 || (found_must_contain
== NULL
)) {
395 return ldb_operr(ldb
);
398 /* Check the delete-protected attributes list */
399 msg
= ac
->search_res
->message
;
400 for (l
= del_prot_attributes
; *l
!= NULL
; l
++) {
401 struct ldb_message_element
*el
;
403 el
= ldb_msg_find_element(ac
->msg
, *l
);
406 * It was not specified in the add or modify,
407 * so it doesn't need to be in the stored record
412 found
= str_list_check_ci(must_contain
, *l
);
414 found
= str_list_check_ci(may_contain
, *l
);
416 if (found
&& (ldb_msg_find_element(msg
, *l
) == NULL
)) {
417 ldb_asprintf_errstring(ldb
, "objectclass_attrs: delete protected attribute '%s' on entry '%s' missing!",
419 ldb_dn_get_linearized(msg
->dn
));
420 return LDB_ERR_UNWILLING_TO_PERFORM
;
424 /* Check if all specified attributes are valid in the given
425 * objectclasses and if they meet additional schema restrictions. */
426 for (i
= 0; i
< msg
->num_elements
; i
++) {
427 attr
= dsdb_attribute_by_lDAPDisplayName(ac
->schema
,
428 msg
->elements
[i
].name
);
430 if (ldb_request_get_control(ac
->req
, DSDB_CONTROL_DBCHECK
)) {
431 /* allow this to make it possible for dbcheck
432 to remove bad attributes */
435 return ldb_operr(ldb
);
438 /* We can use "str_list_check" with "strcmp" here since the
439 * attribute information from the schema are always equal
441 found
= str_list_check(must_contain
, attr
->lDAPDisplayName
);
443 str_list_remove(found_must_contain
, attr
->lDAPDisplayName
);
445 found
= str_list_check(may_contain
, attr
->lDAPDisplayName
);
448 found
= str_list_check(harmless_attrs
, attr
->lDAPDisplayName
);
451 /* we allow this for dbcheck to fix the rest of this broken entry */
452 if (!ldb_request_get_control(ac
->req
, DSDB_CONTROL_DBCHECK
) ||
453 ac
->req
->operation
== LDB_ADD
) {
454 ldb_asprintf_errstring(ldb
, "objectclass_attrs: attribute '%s' on entry '%s' does not exist in the specified objectclasses!",
455 msg
->elements
[i
].name
,
456 ldb_dn_get_linearized(msg
->dn
));
457 return LDB_ERR_OBJECT_CLASS_VIOLATION
;
463 * We skip this check under dbcheck to allow fixing of other
464 * attributes even if an attribute is missing. This matters
465 * for CN=RID Set as the required attribute rIDNextRid is not
468 if (found_must_contain
[0] != NULL
&&
469 ldb_msg_check_string_attribute(msg
, "isDeleted", "TRUE") == 0) {
471 for (i
= 0; found_must_contain
[i
] != NULL
; i
++) {
472 const struct dsdb_attribute
*broken_attr
= dsdb_attribute_by_lDAPDisplayName(ac
->schema
,
473 found_must_contain
[i
]);
475 bool replicated
= (broken_attr
->systemFlags
&
476 (DS_FLAG_ATTR_NOT_REPLICATED
| DS_FLAG_ATTR_IS_CONSTRUCTED
)) == 0;
479 ldb_asprintf_errstring(ldb
, "objectclass_attrs: at least one mandatory "
480 "attribute ('%s') on entry '%s' wasn't specified!",
481 found_must_contain
[i
],
482 ldb_dn_get_linearized(msg
->dn
));
483 return LDB_ERR_OBJECT_CLASS_VIOLATION
;
490 * Before really adding an attribute in the database,
491 * let's check that we can translate it into a dsdb_attribute and
492 * that we can find a valid syntax object.
493 * If not it's better to reject this attribute than not be able
494 * to start samba next time due to schema being unloadable.
496 struct dsdb_attribute
*att
= talloc(ac
, struct dsdb_attribute
);
497 const struct dsdb_syntax
*attrSyntax
;
500 status
= dsdb_attribute_from_ldb(NULL
, msg
, att
);
501 if (!W_ERROR_IS_OK(status
)) {
502 ldb_set_errstring(ldb
,
503 "objectclass: failed to translate the schemaAttribute to a dsdb_attribute");
504 return LDB_ERR_UNWILLING_TO_PERFORM
;
507 attrSyntax
= dsdb_syntax_for_attribute(att
);
509 ldb_set_errstring(ldb
,
510 "objectclass: unknown attribute syntax");
511 return LDB_ERR_UNWILLING_TO_PERFORM
;
514 return ldb_module_done(ac
->req
, ac
->mod_ares
->controls
,
515 ac
->mod_ares
->response
, LDB_SUCCESS
);
518 static int get_search_callback(struct ldb_request
*req
, struct ldb_reply
*ares
)
520 struct ldb_context
*ldb
;
521 struct oc_context
*ac
;
524 ac
= talloc_get_type(req
->context
, struct oc_context
);
525 ldb
= ldb_module_get_ctx(ac
->module
);
528 return ldb_module_done(ac
->req
, NULL
, NULL
,
529 LDB_ERR_OPERATIONS_ERROR
);
531 if (ares
->error
!= LDB_SUCCESS
) {
532 return ldb_module_done(ac
->req
, ares
->controls
,
533 ares
->response
, ares
->error
);
536 ldb_reset_err_string(ldb
);
538 switch (ares
->type
) {
539 case LDB_REPLY_ENTRY
:
540 if (ac
->search_res
!= NULL
) {
541 ldb_set_errstring(ldb
, "Too many results");
543 return ldb_module_done(ac
->req
, NULL
, NULL
,
544 LDB_ERR_OPERATIONS_ERROR
);
547 ac
->search_res
= talloc_steal(ac
, ares
);
550 case LDB_REPLY_REFERRAL
:
557 ret
= attr_handler2(ac
);
558 if (ret
!= LDB_SUCCESS
) {
559 return ldb_module_done(ac
->req
, NULL
, NULL
, ret
);
567 static int oc_op_callback(struct ldb_request
*req
, struct ldb_reply
*ares
)
569 struct oc_context
*ac
;
570 struct ldb_context
*ldb
;
571 struct ldb_request
*search_req
;
572 struct ldb_dn
*base_dn
;
574 static const char *attrs
[] = {"nTSecurityDescriptor", "*", NULL
};
576 ac
= talloc_get_type(req
->context
, struct oc_context
);
577 ldb
= ldb_module_get_ctx(ac
->module
);
580 return ldb_module_done(ac
->req
, NULL
, NULL
,
581 LDB_ERR_OPERATIONS_ERROR
);
584 if (ares
->type
== LDB_REPLY_REFERRAL
) {
585 return ldb_module_send_referral(ac
->req
, ares
->referral
);
588 if (ares
->error
!= LDB_SUCCESS
) {
589 return ldb_module_done(ac
->req
, ares
->controls
, ares
->response
,
593 if (ares
->type
!= LDB_REPLY_DONE
) {
595 return ldb_module_done(ac
->req
, NULL
, NULL
,
596 LDB_ERR_OPERATIONS_ERROR
);
599 ac
->search_res
= NULL
;
600 ac
->mod_ares
= talloc_steal(ac
, ares
);
602 /* This looks up all attributes of our just added/modified entry */
603 base_dn
= ac
->req
->operation
== LDB_ADD
? ac
->req
->op
.add
.message
->dn
604 : ac
->req
->op
.mod
.message
->dn
;
605 ret
= ldb_build_search_req(&search_req
, ldb
, ac
, base_dn
,
606 LDB_SCOPE_BASE
, "(objectClass=*)",
608 get_search_callback
, ac
->req
);
609 LDB_REQ_SET_LOCATION(search_req
);
610 if (ret
!= LDB_SUCCESS
) {
611 return ldb_module_done(ac
->req
, NULL
, NULL
, ret
);
614 ret
= ldb_request_add_control(search_req
, LDB_CONTROL_SHOW_RECYCLED_OID
,
616 if (ret
!= LDB_SUCCESS
) {
617 return ldb_module_done(ac
->req
, NULL
, NULL
, ret
);
620 ret
= ldb_next_request(ac
->module
, search_req
);
621 if (ret
!= LDB_SUCCESS
) {
622 return ldb_module_done(ac
->req
, NULL
, NULL
, ret
);
625 /* "ldb_module_done" isn't called here since we need to do additional
626 * checks. It is called at the end of "attr_handler2". */
630 static int objectclass_attrs_add(struct ldb_module
*module
,
631 struct ldb_request
*req
)
633 struct ldb_context
*ldb
;
634 struct oc_context
*ac
;
636 ldb
= ldb_module_get_ctx(module
);
638 ldb_debug(ldb
, LDB_DEBUG_TRACE
, "objectclass_attrs_add\n");
640 /* do not manipulate our control entries */
641 if (ldb_dn_is_special(req
->op
.add
.message
->dn
)) {
642 return ldb_next_request(module
, req
);
645 ac
= oc_init_context(module
, req
);
647 return ldb_operr(ldb
);
650 /* without schema, there isn't much to do here */
651 if (ac
->schema
== NULL
) {
653 return ldb_next_request(module
, req
);
656 return attr_handler(ac
);
659 static int objectclass_attrs_modify(struct ldb_module
*module
,
660 struct ldb_request
*req
)
662 struct ldb_context
*ldb
;
663 struct ldb_control
*sd_propagation_control
;
666 struct oc_context
*ac
;
668 ldb
= ldb_module_get_ctx(module
);
670 ldb_debug(ldb
, LDB_DEBUG_TRACE
, "objectclass_attrs_modify\n");
672 /* do not manipulate our control entries */
673 if (ldb_dn_is_special(req
->op
.mod
.message
->dn
)) {
674 return ldb_next_request(module
, req
);
677 sd_propagation_control
= ldb_request_get_control(req
,
678 DSDB_CONTROL_SEC_DESC_PROPAGATION_OID
);
679 if (sd_propagation_control
!= NULL
) {
680 if (req
->op
.mod
.message
->num_elements
!= 1) {
681 return ldb_module_operr(module
);
683 ret
= strcmp(req
->op
.mod
.message
->elements
[0].name
,
684 "nTSecurityDescriptor");
686 return ldb_module_operr(module
);
689 return ldb_next_request(module
, req
);
692 ac
= oc_init_context(module
, req
);
694 return ldb_operr(ldb
);
697 /* without schema, there isn't much to do here */
698 if (ac
->schema
== NULL
) {
700 return ldb_next_request(module
, req
);
703 return attr_handler(ac
);
706 static const struct ldb_module_ops ldb_objectclass_attrs_module_ops
= {
707 .name
= "objectclass_attrs",
708 .add
= objectclass_attrs_add
,
709 .modify
= objectclass_attrs_modify
712 int ldb_objectclass_attrs_module_init(const char *version
)
714 LDB_MODULE_CHECK_VERSION(version
);
715 return ldb_register_module(&ldb_objectclass_attrs_module_ops
);