4 Copyright (C) Simo Sorce 2005-2008
5 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2007-2009
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/>.
24 * Component: ldb extended dn control module
26 * Description: this module builds a special dn for returned search
27 * results, and fixes some other aspects of the result (returned case issues)
35 #include "ldb/include/ldb.h"
36 #include "ldb/include/ldb_errors.h"
37 #include "ldb/include/ldb_module.h"
38 #include "libcli/security/security.h"
39 #include "librpc/gen_ndr/ndr_misc.h"
40 #include "librpc/gen_ndr/ndr_security.h"
41 #include "librpc/ndr/libndr.h"
42 #include "dsdb/samdb/samdb.h"
45 struct extended_dn_out_private {
48 struct dsdb_openldap_dereference_control *dereference_control;
52 /* Do the lazy init of the derererence control */
54 static int extended_dn_out_dereference_setup_control(struct ldb_context *ldb, struct extended_dn_out_private *p)
56 const struct dsdb_schema *schema;
57 struct dsdb_openldap_dereference_control *dereference_control;
58 struct dsdb_attribute *cur;
61 if (p->dereference_control) {
65 schema = dsdb_get_schema(ldb, p);
67 /* No schema on this DB (yet) */
71 p->dereference_control = dereference_control
72 = talloc_zero(p, struct dsdb_openldap_dereference_control);
74 if (!p->dereference_control) {
78 for (cur = schema->attributes; cur; cur = cur->next) {
79 if (dsdb_dn_oid_to_format(cur->syntax->ldap_oid) != DSDB_NORMAL_DN) {
82 dereference_control->dereference
83 = talloc_realloc(p, dereference_control->dereference,
84 struct dsdb_openldap_dereference *, i + 2);
85 if (!dereference_control) {
88 dereference_control->dereference[i] = talloc(dereference_control->dereference,
89 struct dsdb_openldap_dereference);
90 if (!dereference_control->dereference[i]) {
93 dereference_control->dereference[i]->source_attribute = cur->lDAPDisplayName;
94 dereference_control->dereference[i]->dereference_attribute = p->attrs;
96 dereference_control->dereference[i] = NULL;
101 static char **copy_attrs(void *mem_ctx, const char * const * attrs)
106 for (num = 0; attrs[num]; num++);
108 nattrs = talloc_array(mem_ctx, char *, num + 1);
109 if (!nattrs) return NULL;
111 for(i = 0; i < num; i++) {
112 nattrs[i] = talloc_strdup(nattrs, attrs[i]);
123 static bool add_attrs(void *mem_ctx, char ***attrs, const char *attr)
128 for (num = 0; (*attrs)[num]; num++);
130 nattrs = talloc_realloc(mem_ctx, *attrs, char *, num + 2);
131 if (!nattrs) return false;
135 nattrs[num] = talloc_strdup(nattrs, attr);
136 if (!nattrs[num]) return false;
138 nattrs[num + 1] = NULL;
143 /* Fix the DN so that the relative attribute names are in upper case so that the DN:
144 cn=Adminstrator,cn=users,dc=samba,dc=example,dc=com becomes
145 CN=Adminstrator,CN=users,DC=samba,DC=example,DC=com
149 static int fix_dn(struct ldb_context *ldb, struct ldb_dn *dn)
152 char *upper_rdn_attr;
154 for (i=0; i < ldb_dn_get_comp_num(dn); i++) {
155 /* We need the attribute name in upper case */
156 upper_rdn_attr = strupper_talloc(dn,
157 ldb_dn_get_component_name(dn, i));
158 if (!upper_rdn_attr) {
162 /* And replace it with CN=foo (we need the attribute in upper case */
163 ret = ldb_dn_set_component(dn, i, upper_rdn_attr,
164 *ldb_dn_get_component_val(dn, i));
165 talloc_free(upper_rdn_attr);
166 if (ret != LDB_SUCCESS) {
173 /* Inject the extended DN components, so the DN cn=Adminstrator,cn=users,dc=samba,dc=example,dc=com becomes
174 <GUID=541203ae-f7d6-47ef-8390-bfcf019f9583>;<SID=S-1-5-21-4177067393-1453636373-93818737-500>;cn=Adminstrator,cn=users,dc=samba,dc=example,dc=com */
176 static int inject_extended_dn_out(struct ldb_reply *ares,
177 struct ldb_context *ldb,
183 const DATA_BLOB *guid_blob;
184 const DATA_BLOB *sid_blob;
186 guid_blob = ldb_msg_find_ldb_val(ares->message, "objectGUID");
187 sid_blob = ldb_msg_find_ldb_val(ares->message, "objectSid");
190 ldb_set_errstring(ldb, "Did not find objectGUID to inject into extended DN");
191 return LDB_ERR_OPERATIONS_ERROR;
194 ret = ldb_dn_set_extended_component(ares->message->dn, "GUID", guid_blob);
195 if (ret != LDB_SUCCESS) {
199 ret = ldb_dn_set_extended_component(ares->message->dn, "SID", sid_blob);
200 if (ret != LDB_SUCCESS) {
206 ldb_msg_remove_attr(ares->message, "objectGUID");
209 if (sid_blob && remove_sid) {
210 ldb_msg_remove_attr(ares->message, "objectSid");
216 static int handle_dereference_openldap(struct ldb_dn *dn,
217 struct dsdb_openldap_dereference_result **dereference_attrs,
218 const char *attr, const DATA_BLOB *val)
220 const struct ldb_val *entryUUIDblob, *sid_blob;
221 struct ldb_message fake_msg; /* easier to use routines that expect an ldb_message */
224 fake_msg.num_elements = 0;
226 /* Look for this attribute in the returned control */
227 for (j = 0; dereference_attrs && dereference_attrs[j]; j++) {
228 struct ldb_val source_dn = data_blob_string_const(dereference_attrs[j]->dereferenced_dn);
229 if (ldb_attr_cmp(dereference_attrs[j]->source_attribute, attr) == 0
230 && data_blob_cmp(&source_dn, val) == 0) {
231 fake_msg.num_elements = dereference_attrs[j]->num_attributes;
232 fake_msg.elements = dereference_attrs[j]->attributes;
236 if (!fake_msg.num_elements) {
239 /* Look for an OpenLDAP entryUUID */
241 entryUUIDblob = ldb_msg_find_ldb_val(&fake_msg, "entryUUID");
244 struct ldb_val guid_blob;
247 status = GUID_from_data_blob(entryUUIDblob, &guid);
249 if (!NT_STATUS_IS_OK(status)) {
250 return LDB_ERR_INVALID_DN_SYNTAX;
252 status = GUID_to_ndr_blob(&guid, dn, &guid_blob);
253 if (!NT_STATUS_IS_OK(status)) {
254 return LDB_ERR_INVALID_DN_SYNTAX;
257 ldb_dn_set_extended_component(dn, "GUID", &guid_blob);
260 sid_blob = ldb_msg_find_ldb_val(&fake_msg, "objectSid");
262 /* Look for the objectSid */
264 ldb_dn_set_extended_component(dn, "SID", sid_blob);
269 static int handle_dereference_fds(struct ldb_dn *dn,
270 struct dsdb_openldap_dereference_result **dereference_attrs,
271 const char *attr, const DATA_BLOB *val)
273 const struct ldb_val *nsUniqueIdBlob, *sidBlob;
274 struct ldb_message fake_msg; /* easier to use routines that expect an ldb_message */
277 fake_msg.num_elements = 0;
279 /* Look for this attribute in the returned control */
280 for (j = 0; dereference_attrs && dereference_attrs[j]; j++) {
281 struct ldb_val source_dn = data_blob_string_const(dereference_attrs[j]->dereferenced_dn);
282 if (ldb_attr_cmp(dereference_attrs[j]->source_attribute, attr) == 0
283 && data_blob_cmp(&source_dn, val) == 0) {
284 fake_msg.num_elements = dereference_attrs[j]->num_attributes;
285 fake_msg.elements = dereference_attrs[j]->attributes;
289 if (!fake_msg.num_elements) {
293 /* Look for the nsUniqueId */
295 nsUniqueIdBlob = ldb_msg_find_ldb_val(&fake_msg, "nsUniqueId");
296 if (nsUniqueIdBlob) {
298 struct ldb_val guid_blob;
301 status = NS_GUID_from_string((char *)nsUniqueIdBlob->data, &guid);
303 if (!NT_STATUS_IS_OK(status)) {
304 return LDB_ERR_INVALID_DN_SYNTAX;
306 status = GUID_to_ndr_blob(&guid, dn, &guid_blob);
307 if (!NT_STATUS_IS_OK(status)) {
308 return LDB_ERR_INVALID_DN_SYNTAX;
311 ldb_dn_set_extended_component(dn, "GUID", &guid_blob);
314 /* Look for the objectSid */
316 sidBlob = ldb_msg_find_ldb_val(&fake_msg, "sambaSID");
318 enum ndr_err_code ndr_err;
320 struct ldb_val sid_blob;
323 sid = dom_sid_parse_length(NULL, sidBlob);
326 return LDB_ERR_INVALID_DN_SYNTAX;
329 ndr_err = ndr_push_struct_blob(&sid_blob, NULL, sid,
330 (ndr_push_flags_fn_t)ndr_push_dom_sid);
332 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
333 return LDB_ERR_INVALID_DN_SYNTAX;
336 ldb_dn_set_extended_component(dn, "SID", &sid_blob);
342 struct extended_search_context {
343 struct ldb_module *module;
344 const struct dsdb_schema *schema;
345 struct ldb_request *req;
352 static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
353 int (*handle_dereference)(struct ldb_dn *dn,
354 struct dsdb_openldap_dereference_result **dereference_attrs,
355 const char *attr, const DATA_BLOB *val))
357 struct extended_search_context *ac;
358 struct ldb_control *control;
359 struct dsdb_openldap_dereference_result_control *dereference_control = NULL;
362 struct ldb_message *msg;
363 struct extended_dn_out_private *p;
364 struct ldb_context *ldb;
365 bool have_reveal_control=false, checked_reveal_control=false;
367 ac = talloc_get_type(req->context, struct extended_search_context);
368 p = talloc_get_type(ldb_module_get_private(ac->module), struct extended_dn_out_private);
369 ldb = ldb_module_get_ctx(ac->module);
371 return ldb_module_done(ac->req, NULL, NULL,
372 LDB_ERR_OPERATIONS_ERROR);
374 if (ares->error != LDB_SUCCESS) {
375 return ldb_module_done(ac->req, ares->controls,
376 ares->response, ares->error);
381 switch (ares->type) {
382 case LDB_REPLY_REFERRAL:
383 return ldb_module_send_referral(ac->req, ares->referral);
386 return ldb_module_done(ac->req, ares->controls,
387 ares->response, LDB_SUCCESS);
388 case LDB_REPLY_ENTRY:
392 if (p && p->normalise) {
393 ret = fix_dn(ldb, ares->message->dn);
394 if (ret != LDB_SUCCESS) {
395 return ldb_module_done(ac->req, NULL, NULL, ret);
400 /* for each record returned post-process to add any derived
401 attributes that have been asked for */
402 ret = inject_extended_dn_out(ares, ldb,
403 ac->extended_type, ac->remove_guid,
405 if (ret != LDB_SUCCESS) {
406 return ldb_module_done(ac->req, NULL, NULL, ret);
410 if ((p && p->normalise) || ac->inject) {
411 const struct ldb_val *val = ldb_msg_find_ldb_val(ares->message, "distinguishedName");
413 ldb_msg_remove_attr(ares->message, "distinguishedName");
415 ret = ldb_msg_add_steal_string(ares->message, "distinguishedName",
416 ldb_dn_get_extended_linearized(ares->message, ares->message->dn, ac->extended_type));
418 ret = ldb_msg_add_linearized_dn(ares->message,
422 if (ret != LDB_SUCCESS) {
428 if (p && p->dereference) {
429 control = ldb_reply_get_control(ares, DSDB_OPENLDAP_DEREFERENCE_CONTROL);
431 if (control && control->data) {
432 dereference_control = talloc_get_type(control->data, struct dsdb_openldap_dereference_result_control);
436 /* Walk the returned elements (but only if we have a schema to
437 * interpret the list with) */
438 for (i = 0; ac->schema && i < msg->num_elements; i++) {
439 bool make_extended_dn;
440 const struct dsdb_attribute *attribute;
441 attribute = dsdb_attribute_by_lDAPDisplayName(ac->schema, msg->elements[i].name);
447 /* If we are also in 'normalise' mode, then
448 * fix the attribute names to be in the
450 msg->elements[i].name = talloc_strdup(msg->elements, attribute->lDAPDisplayName);
451 if (!msg->elements[i].name) {
453 return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
457 /* distinguishedName has been dealt with above */
458 if (ldb_attr_cmp(msg->elements[i].name, "distinguishedName") == 0) {
462 /* Look to see if this attributeSyntax is a DN */
463 if (dsdb_dn_oid_to_format(attribute->syntax->ldap_oid) == DSDB_INVALID_DN) {
467 make_extended_dn = ac->inject;
469 /* Always show plain DN in case of Object(OR-Name) syntax */
470 if (make_extended_dn) {
471 make_extended_dn = (strcmp(attribute->syntax->ldap_oid, DSDB_SYNTAX_OR_NAME) != 0);
474 for (j = 0; j < msg->elements[i].num_values; j++) {
477 struct dsdb_dn *dsdb_dn = NULL;
478 struct ldb_val *plain_dn = &msg->elements[i].values[j];
480 if (!checked_reveal_control) {
481 have_reveal_control =
482 ldb_request_get_control(req, LDB_CONTROL_REVEAL_INTERNALS) != NULL;
483 checked_reveal_control = true;
486 /* this is a fast method for detecting deleted
487 linked attributes, working on the unparsed
489 if (dsdb_dn_is_deleted_val(plain_dn) && !have_reveal_control) {
490 /* it's a deleted linked attribute,
491 and we don't have the reveal control */
492 memmove(&msg->elements[i].values[j],
493 &msg->elements[i].values[j+1],
494 (msg->elements[i].num_values-(j+1))*sizeof(struct ldb_val));
495 msg->elements[i].num_values--;
501 dsdb_dn = dsdb_dn_parse(msg, ldb, plain_dn, attribute->syntax->ldap_oid);
503 if (!dsdb_dn || !ldb_dn_validate(dsdb_dn->dn)) {
504 ldb_asprintf_errstring(ldb,
505 "could not parse %.*s in %s on %s as a %s DN",
506 (int)plain_dn->length, plain_dn->data,
507 msg->elements[i].name, ldb_dn_get_linearized(msg->dn),
508 attribute->syntax->ldap_oid);
509 talloc_free(dsdb_dn);
510 return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_INVALID_DN_SYNTAX);
514 /* don't let users see the internal extended
516 if (!have_reveal_control) {
517 const char *accept[] = { "GUID", "SID", "WKGUID", NULL };
518 ldb_dn_extended_filter(dn, accept);
522 ret = fix_dn(ldb, dn);
523 if (ret != LDB_SUCCESS) {
524 talloc_free(dsdb_dn);
525 return ldb_module_done(ac->req, NULL, NULL, ret);
529 /* If we are running in dereference mode (such
530 * as against OpenLDAP) then the DN in the msg
531 * above does not contain the extended values,
532 * and we need to look in the dereference
535 /* Look for this value in the attribute */
537 if (dereference_control) {
538 ret = handle_dereference(dn,
539 dereference_control->attributes,
540 msg->elements[i].name,
541 &msg->elements[i].values[j]);
542 if (ret != LDB_SUCCESS) {
543 talloc_free(dsdb_dn);
544 return ldb_module_done(ac->req, NULL, NULL, ret);
548 if (make_extended_dn) {
549 dn_str = dsdb_dn_get_extended_linearized(msg->elements[i].values,
550 dsdb_dn, ac->extended_type);
552 dn_str = dsdb_dn_get_linearized(msg->elements[i].values,
558 talloc_free(dsdb_dn);
559 return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
561 msg->elements[i].values[j] = data_blob_string_const(dn_str);
562 talloc_free(dsdb_dn);
564 if (msg->elements[i].num_values == 0) {
565 /* we've deleted all of the values from this
566 * element - remove the element */
567 memmove(&msg->elements[i],
569 (msg->num_elements-(i+1))*sizeof(struct ldb_message_element));
574 return ldb_module_send_entry(ac->req, msg, ares->controls);
577 static int extended_callback_ldb(struct ldb_request *req, struct ldb_reply *ares)
579 return extended_callback(req, ares, NULL);
582 static int extended_callback_openldap(struct ldb_request *req, struct ldb_reply *ares)
584 return extended_callback(req, ares, handle_dereference_openldap);
587 static int extended_callback_fds(struct ldb_request *req, struct ldb_reply *ares)
589 return extended_callback(req, ares, handle_dereference_fds);
592 static int extended_dn_out_search(struct ldb_module *module, struct ldb_request *req,
593 int (*callback)(struct ldb_request *req, struct ldb_reply *ares))
595 struct ldb_control *control;
596 struct ldb_control *storage_format_control;
597 struct ldb_extended_dn_control *extended_ctrl = NULL;
598 struct extended_search_context *ac;
599 struct ldb_request *down_req;
601 const char * const *const_attrs;
602 struct ldb_context *ldb = ldb_module_get_ctx(module);
606 struct extended_dn_out_private *p = talloc_get_type(ldb_module_get_private(module), struct extended_dn_out_private);
608 /* The schema manipulation does not apply to special DNs */
609 if (ldb_dn_is_special(req->op.search.base)) {
610 return ldb_next_request(module, req);
613 /* check if there's an extended dn control */
614 control = ldb_request_get_control(req, LDB_CONTROL_EXTENDED_DN_OID);
615 if (control && control->data) {
616 extended_ctrl = talloc_get_type(control->data, struct ldb_extended_dn_control);
617 if (!extended_ctrl) {
618 return LDB_ERR_PROTOCOL_ERROR;
622 /* Look to see if, as we are in 'store DN+GUID+SID' mode, the
623 * client is after the storage format (to fill in linked
625 storage_format_control = ldb_request_get_control(req, DSDB_CONTROL_DN_STORAGE_FORMAT_OID);
626 if (!control && storage_format_control && storage_format_control->data) {
627 extended_ctrl = talloc_get_type(storage_format_control->data, struct ldb_extended_dn_control);
628 if (!extended_ctrl) {
629 ldb_set_errstring(ldb, "extended_dn_out: extended_ctrl was of the wrong data type");
630 return LDB_ERR_PROTOCOL_ERROR;
634 ac = talloc_zero(req, struct extended_search_context);
640 ac->schema = dsdb_get_schema(ldb, ac);
643 ac->remove_guid = false;
644 ac->remove_sid = false;
646 const_attrs = req->op.search.attrs;
648 /* We only need to do special processing if we were asked for
649 * the extended DN, or we are 'store DN+GUID+SID'
650 * (!dereference) mode. (This is the normal mode for LDB on
652 if (control || (storage_format_control && p && !p->dereference)) {
655 ac->extended_type = extended_ctrl->type;
657 ac->extended_type = 0;
660 /* check if attrs only is specified, in that case check wether we need to modify them */
661 if (req->op.search.attrs && !is_attr_in_list(req->op.search.attrs, "*")) {
662 if (! is_attr_in_list(req->op.search.attrs, "objectGUID")) {
663 ac->remove_guid = true;
665 if (! is_attr_in_list(req->op.search.attrs, "objectSid")) {
666 ac->remove_sid = true;
668 if (ac->remove_guid || ac->remove_sid) {
669 new_attrs = copy_attrs(ac, req->op.search.attrs);
670 if (new_attrs == NULL) {
674 if (ac->remove_guid) {
675 if (!add_attrs(ac, &new_attrs, "objectGUID"))
676 return ldb_operr(ldb);
678 if (ac->remove_sid) {
679 if (!add_attrs(ac, &new_attrs, "objectSid"))
680 return ldb_operr(ldb);
682 const_attrs = (const char * const *)new_attrs;
687 ret = ldb_build_search_req_ex(&down_req,
690 req->op.search.scope,
696 LDB_REQ_SET_LOCATION(down_req);
697 if (ret != LDB_SUCCESS) {
701 /* mark extended DN and storage format controls as done */
703 critical = control->critical;
704 control->critical = 0;
707 if (storage_format_control) {
708 storage_format_control->critical = 0;
711 /* Add in dereference control, if we were asked to, we are
712 * using the 'dereference' mode (such as with an OpenLDAP
713 * backend) and have the control prepared */
714 if (control && p && p->dereference) {
715 ret = extended_dn_out_dereference_setup_control(ldb, p);
716 if (ret != LDB_SUCCESS) {
720 /* We should always have this, but before the schema
721 * is with us, things get tricky */
722 if (p->dereference_control) {
724 /* This control must *not* be critical,
725 * because if this particular request did not
726 * return any dereferencable attributes in the
727 * end, then OpenLDAP will reply with
728 * unavailableCriticalExtension, rather than
729 * just an empty return control */
730 ret = ldb_request_add_control(down_req,
731 DSDB_OPENLDAP_DEREFERENCE_CONTROL,
732 false, p->dereference_control);
733 if (ret != LDB_SUCCESS) {
739 /* perform the search */
740 return ldb_next_request(module, down_req);
743 static int extended_dn_out_ldb_search(struct ldb_module *module, struct ldb_request *req)
745 return extended_dn_out_search(module, req, extended_callback_ldb);
748 static int extended_dn_out_openldap_search(struct ldb_module *module, struct ldb_request *req)
750 return extended_dn_out_search(module, req, extended_callback_openldap);
753 static int extended_dn_out_fds_search(struct ldb_module *module, struct ldb_request *req)
755 return extended_dn_out_search(module, req, extended_callback_fds);
758 static int extended_dn_out_ldb_init(struct ldb_module *module)
762 struct extended_dn_out_private *p = talloc(module, struct extended_dn_out_private);
763 struct dsdb_extended_dn_store_format *dn_format;
765 ldb_module_set_private(module, p);
768 return ldb_oom(ldb_module_get_ctx(module));
771 dn_format = talloc(p, struct dsdb_extended_dn_store_format);
774 return ldb_oom(ldb_module_get_ctx(module));
777 dn_format->store_extended_dn_in_ldb = true;
778 ret = ldb_set_opaque(ldb_module_get_ctx(module), DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME, dn_format);
779 if (ret != LDB_SUCCESS) {
784 p->dereference = false;
785 p->normalise = false;
787 ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID);
788 if (ret != LDB_SUCCESS) {
789 ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR,
790 "extended_dn_out: Unable to register control with rootdse!\n");
791 return ldb_operr(ldb_module_get_ctx(module));
794 return ldb_next_init(module);
797 static int extended_dn_out_dereference_init(struct ldb_module *module, const char *attrs[])
800 struct extended_dn_out_private *p = talloc_zero(module, struct extended_dn_out_private);
801 struct dsdb_extended_dn_store_format *dn_format;
803 ldb_module_set_private(module, p);
806 return ldb_module_oom(module);
809 dn_format = talloc(p, struct dsdb_extended_dn_store_format);
812 return ldb_module_oom(module);
815 dn_format->store_extended_dn_in_ldb = false;
817 ret = ldb_set_opaque(ldb_module_get_ctx(module), DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME, dn_format);
818 if (ret != LDB_SUCCESS) {
823 p->dereference = true;
826 /* At the moment, servers that need dereference also need the
827 * DN and attribute names to be normalised */
830 ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID);
831 if (ret != LDB_SUCCESS) {
832 ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR,
833 "extended_dn_out: Unable to register control with rootdse!\n");
834 return ldb_operr(ldb_module_get_ctx(module));
837 return ldb_next_init(module);
840 static int extended_dn_out_openldap_init(struct ldb_module *module)
842 static const char *attrs[] = {
848 return extended_dn_out_dereference_init(module, attrs);
851 static int extended_dn_out_fds_init(struct ldb_module *module)
853 static const char *attrs[] = {
859 return extended_dn_out_dereference_init(module, attrs);
862 static const struct ldb_module_ops ldb_extended_dn_out_ldb_module_ops = {
863 .name = "extended_dn_out_ldb",
864 .search = extended_dn_out_ldb_search,
865 .init_context = extended_dn_out_ldb_init,
868 static const struct ldb_module_ops ldb_extended_dn_out_openldap_module_ops = {
869 .name = "extended_dn_out_openldap",
870 .search = extended_dn_out_openldap_search,
871 .init_context = extended_dn_out_openldap_init,
874 static const struct ldb_module_ops ldb_extended_dn_out_fds_module_ops = {
875 .name = "extended_dn_out_fds",
876 .search = extended_dn_out_fds_search,
877 .init_context = extended_dn_out_fds_init,
881 initialise the module
883 _PUBLIC_ int ldb_extended_dn_out_module_init(const char *version)
886 LDB_MODULE_CHECK_VERSION(version);
887 ret = ldb_register_module(&ldb_extended_dn_out_ldb_module_ops);
888 if (ret != LDB_SUCCESS) {
891 ret = ldb_register_module(&ldb_extended_dn_out_openldap_module_ops);
892 if (ret != LDB_SUCCESS) {
895 ret = ldb_register_module(&ldb_extended_dn_out_fds_module_ops);
896 if (ret != LDB_SUCCESS) {