2 /* A handy macro to report Out of Memory conditions */
3 #define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
5 /* The type of search callback functions */
6 typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *);
8 /* The special DN from which the local and remote base DNs are fetched */
9 #define MAP_DN_NAME "@MAP"
10 #define MAP_DN_FROM "@FROM"
11 #define MAP_DN_TO "@TO"
13 /* Private data structures
14 * ======================= */
17 struct map_reply *next;
18 struct ldb_reply *remote;
19 struct ldb_reply *local;
22 /* Context data for mapped requests */
25 struct ldb_module *module;
26 struct ldb_request *req;
28 struct ldb_dn *local_dn;
29 const struct ldb_parse_tree *local_tree;
30 const char * const *local_attrs;
31 const char * const *remote_attrs;
32 const char * const *all_attrs;
34 struct ldb_message *local_msg;
35 struct ldb_request *remote_req;
37 struct map_reply *r_list;
38 struct map_reply *r_current;
42 * ================= */
44 /* The following definitions come from lib/ldb/modules/ldb_map.c */
45 const struct ldb_map_context *map_get_context(struct ldb_module *module);
46 struct map_context *map_init_context(struct ldb_module *module,
47 struct ldb_request *req);
49 int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request);
51 bool map_check_local_db(struct ldb_module *module);
52 bool map_attr_check_remote(const struct ldb_map_context *data, const char *attr);
53 bool ldb_dn_check_local(struct ldb_module *module, struct ldb_dn *dn);
55 const struct ldb_map_attribute *map_attr_find_local(const struct ldb_map_context *data, const char *name);
56 const struct ldb_map_attribute *map_attr_find_remote(const struct ldb_map_context *data, const char *name);
58 const char *map_attr_map_local(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
59 const char *map_attr_map_remote(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
60 int map_attrs_merge(struct ldb_module *module, void *mem_ctx, const char ***attrs, const char * const *more_attrs);
62 struct ldb_val ldb_val_map_local(struct ldb_module *module, void *mem_ctx, const struct ldb_map_attribute *map, const struct ldb_val *val);
63 struct ldb_val ldb_val_map_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_map_attribute *map, const struct ldb_val *val);
65 struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
66 struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
67 struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
69 struct ldb_request *map_search_base_req(struct map_context *ac,
71 const char * const *attrs,
72 const struct ldb_parse_tree *tree,
74 ldb_map_callback_t callback);
75 struct ldb_request *map_build_fixup_req(struct map_context *ac,
79 ldb_map_callback_t callback);
80 int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
81 struct ldb_parse_tree **new,
82 const struct ldb_parse_tree *tree,
83 const struct ldb_map_attribute *map);
84 int map_return_fatal_error(struct ldb_request *req,
85 struct ldb_reply *ares);
86 int map_return_normal_error(struct ldb_request *req,
87 struct ldb_reply *ares,
90 int map_return_entry(struct map_context *ac, struct ldb_reply *ares);