/* [<][>][^][v][top][bottom][index][help] */
1 #include "ldb_includes.h"
2
3 /* A handy macro to report Out of Memory conditions */
4 #define map_oom(module) ldb_set_errstring(ldb_module_get_ctx(module), talloc_asprintf(module, "Out of Memory"));
5
6 /* The type of search callback functions */
7 typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *);
8
9 /* The special DN from which the local and remote base DNs are fetched */
10 #define MAP_DN_NAME "@MAP"
11 #define MAP_DN_FROM "@FROM"
12 #define MAP_DN_TO "@TO"
13
14 /* Private data structures
15 * ======================= */
16
17 struct map_reply {
18 struct map_reply *next;
19 struct ldb_reply *remote;
20 struct ldb_reply *local;
21 };
22
23 /* Context data for mapped requests */
24 struct map_context {
25
26 struct ldb_module *module;
27 struct ldb_request *req;
28
29 struct ldb_dn *local_dn;
30 const struct ldb_parse_tree *local_tree;
31 const char * const *local_attrs;
32 const char * const *remote_attrs;
33 const char * const *all_attrs;
34
35 struct ldb_message *local_msg;
36 struct ldb_request *remote_req;
37
38 struct map_reply *r_list;
39 struct map_reply *r_current;
40 };
41
42 /* Common operations
43 * ================= */
44
45 /* The following definitions come from lib/ldb/modules/ldb_map.c */
46 const struct ldb_map_context *map_get_context(struct ldb_module *module);
47 struct map_context *map_init_context(struct ldb_module *module,
48 struct ldb_request *req);
49
50 int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request);
51
52 bool map_check_local_db(struct ldb_module *module);
53 bool map_attr_check_remote(const struct ldb_map_context *data, const char *attr);
54 bool ldb_dn_check_local(struct ldb_module *module, struct ldb_dn *dn);
55
56 const struct ldb_map_attribute *map_attr_find_local(const struct ldb_map_context *data, const char *name);
57 const struct ldb_map_attribute *map_attr_find_remote(const struct ldb_map_context *data, const char *name);
58
59 const char *map_attr_map_local(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
60 const char *map_attr_map_remote(void *mem_ctx, const struct ldb_map_attribute *map, const char *attr);
61 int map_attrs_merge(struct ldb_module *module, void *mem_ctx, const char ***attrs, const char * const *more_attrs);
62
63 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);
64 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
66 struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
67 struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
68 struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn);
69
70 struct ldb_request *map_search_base_req(struct map_context *ac,
71 struct ldb_dn *dn,
72 const char * const *attrs,
73 const struct ldb_parse_tree *tree,
74 void *context,
75 ldb_map_callback_t callback);
76 struct ldb_request *map_build_fixup_req(struct map_context *ac,
77 struct ldb_dn *olddn,
78 struct ldb_dn *newdn,
79 void *context,
80 ldb_map_callback_t callback);
81 int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
82 struct ldb_parse_tree **new,
83 const struct ldb_parse_tree *tree,
84 const struct ldb_map_attribute *map);
85 int map_return_fatal_error(struct ldb_request *req,
86 struct ldb_reply *ares);
87 int map_return_normal_error(struct ldb_request *req,
88 struct ldb_reply *ares,
89 int error);
90
91 int map_return_entry(struct map_context *ac, struct ldb_reply *ares);