summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules/ldb_map.h
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-08-13 23:58:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:33 -0500
commit027583e6de2a6981d1c0e8959e1e37bf758be8f9 (patch)
treef256de0bd3edae21364179eb752b51f98e0bbb2d /source4/lib/ldb/modules/ldb_map.h
parentcf863ef3e37a52de35ec848fa84b129ecb4491ec (diff)
downloadsamba-027583e6de2a6981d1c0e8959e1e37bf758be8f9.tar.gz
samba-027583e6de2a6981d1c0e8959e1e37bf758be8f9.tar.bz2
samba-027583e6de2a6981d1c0e8959e1e37bf758be8f9.zip
r17525: This is a merge from the Google Summer of Code 2006 project by Martin Kühl
<mkhl@samba.org>. Martin took over the work done last year by Jelmer, in last year's SoC. This was a substanital task, as the the ldb modules API changed significantly during the past year, with the addition of async calls. This changeset reimplements and enables the ldb_map ldb module and adapts the example module and test case, both named samba3sam, to the implementation. The ldb_map module supports splitting an ldb database into two parts (called the "local" and "remote" part) and storing the data in one of them (the remote database) in a different format while the other acts as a fallback. This allows ldb to e.g. store to and load data from a remote LDAP server and present it according to the Samba4 schema while still allowing the LDAP to present and modify its data separately. A complex example of this is the samba3sam module (by Jelmer Vernooij), which maps data between the samba3 and samba4 schemas. A simpler example is given by the entryUUID module (by Andrew Bartlett), which handles some of the differences between AD and OpenLDAP in operational attributes. It principally maps objectGUID, to and from entryUUID elements. This is also an example of a module that doesn't use the local backend as fallback storage. This merge also splits the ldb_map.c file into smaller, more manageable parts. (This used to be commit af2bece4d343a9f787b2e3628848b266cec2b9f0)
Diffstat (limited to 'source4/lib/ldb/modules/ldb_map.h')
-rw-r--r--source4/lib/ldb/modules/ldb_map.h89
1 files changed, 59 insertions, 30 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.h b/source4/lib/ldb/modules/ldb_map.h
index 36165a260b..f9e2086ee1 100644
--- a/source4/lib/ldb/modules/ldb_map.h
+++ b/source4/lib/ldb/modules/ldb_map.h
@@ -2,7 +2,8 @@
ldb database library - map backend
Copyright (C) Jelmer Vernooij 2005
- Development sponsored by the Google Summer of Code program
+ Copyright (C) Martin Kuehl <mkhl@samba.org> 2006
+ Development sponsored by the Google Summer of Code program
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -15,12 +16,12 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LDB_MAP_H__
@@ -39,10 +40,21 @@
* while returning too many attributes in ldb_search() doesn't)
*/
+
+/* Name of the internal attribute pointing from the local to the
+ * remote part of a record */
+#define IS_MAPPED "isMapped"
+
+
struct ldb_map_context;
-struct ldb_map_attribute
-{
+/* convert a local ldb_val to a remote ldb_val */
+typedef struct ldb_val (*ldb_map_convert_func) (struct ldb_module *module, void *mem_ctx, const struct ldb_val *val);
+
+#define LDB_MAP_MAX_REMOTE_NAMES 10
+
+/* map from local to remote attribute */
+struct ldb_map_attribute {
const char *local_name; /* local name */
enum ldb_map_attr_type {
@@ -55,8 +67,8 @@ struct ldb_map_attribute
multiple remote attributes. */
} type;
- /* if set, will be called for expressions that contain this attribute */
- struct ldb_parse_tree *(*convert_operator) (struct ldb_map_context *, TALLOC_CTX *ctx, const struct ldb_parse_tree *);
+ /* if set, will be called for search expressions that contain this attribute */
+ struct ldb_parse_tree *(*convert_operator)(const struct ldb_map_context *, TALLOC_CTX *ctx, const struct ldb_parse_tree *);
union {
struct {
@@ -65,43 +77,46 @@ struct ldb_map_attribute
struct {
const char *remote_name;
- struct ldb_val (*convert_local) (struct ldb_module *, TALLOC_CTX *, const struct ldb_val *);
-
+
+ /* Convert local to remote data */
+ ldb_map_convert_func convert_local;
+
+ /* Convert remote to local data */
/* an entry can have convert_remote set to NULL, as long as there as an entry with the same local_name
* that is non-NULL before it. */
- struct ldb_val (*convert_remote) (struct ldb_module *, TALLOC_CTX *, const struct ldb_val *);
+ ldb_map_convert_func convert_remote;
} convert;
struct {
/* Generate the local attribute from remote message */
- struct ldb_message_element *(*generate_local) (
- struct ldb_module *,
- TALLOC_CTX *ctx,
- const char *attr,
- const struct ldb_message *remote);
+ struct ldb_message_element *(*generate_local)(struct ldb_module *, TALLOC_CTX *mem_ctx, const char *remote_attr, const struct ldb_message *remote);
/* Update remote message with information from local message */
- void (*generate_remote) (
- struct ldb_module *,
- const char *local_attr,
- const struct ldb_message *local,
- struct ldb_message *remote_mp,
- struct ldb_message *remote_fb);
+ void (*generate_remote)(struct ldb_module *, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local);
/* Name(s) for this attribute on the remote server. This is an array since
* one local attribute's data can be split up into several attributes
* remotely */
-#define LDB_MAP_MAX_REMOTE_NAMES 10
const char *remote_names[LDB_MAP_MAX_REMOTE_NAMES];
+
+ /* Names of additional remote attributes
+ * required for the generation. NULL
+ * indicates that `local_attr' suffices. */
+ /*
+#define LDB_MAP_MAX_SELF_ATTRIBUTES 10
+ const char *self_attrs[LDB_MAP_MAX_SELF_ATTRIBUTES];
+ */
} generate;
} u;
};
-#define LDB_MAP_MAX_SUBCLASSES 10
-#define LDB_MAP_MAX_MUSTS 10
-#define LDB_MAP_MAX_MAYS 50
-struct ldb_map_objectclass
-{
+
+#define LDB_MAP_MAX_SUBCLASSES 10
+#define LDB_MAP_MAX_MUSTS 10
+#define LDB_MAP_MAX_MAYS 50
+
+/* map from local to remote objectClass */
+struct ldb_map_objectclass {
const char *local_name;
const char *remote_name;
const char *base_classes[LDB_MAP_MAX_SUBCLASSES];
@@ -109,12 +124,26 @@ struct ldb_map_objectclass
const char *mays[LDB_MAP_MAX_MAYS];
};
-struct ldb_map_context
-{
+
+/* private context data */
+struct ldb_map_context {
struct ldb_map_attribute *attribute_maps;
/* NOTE: Always declare base classes first here */
const struct ldb_map_objectclass *objectclass_maps;
- struct ldb_context *mapped_ldb;
+ /* struct ldb_context *mapped_ldb; */
+ const struct ldb_dn *local_base_dn;
+ const struct ldb_dn *remote_base_dn;
};
+/* initialization function */
+int
+ldb_map_init(struct ldb_module *module,
+ const struct ldb_map_attribute *attrs,
+ const struct ldb_map_objectclass *ocls,
+ const char *name);
+
+/* get copy of map_ops */
+struct ldb_module_ops
+ldb_map_get_ops(void);
+
#endif /* __LDB_MAP_H__ */