2 ldb database library - map backend
4 Copyright (C) Jelmer Vernooij 2005
5 Development sponsored by the Google Summer of Code program
7 ** NOTE! The following LGPL license applies to the ldb
8 ** library. This does NOT imply that all of Samba is released
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 /* ldb_map is a skeleton LDB module that can be used for any other modules
30 * that need to map attributes.
32 * The term 'remote' in this header refers to the connection where the
33 * original schema is used on while 'local' means the local connection
34 * that any upper layers will use.
36 * All local attributes will have to have a definition. Not all remote
37 * attributes need a definition as LDB is a lot less strict than LDAP
38 * (in other words, sending unknown attributes to an LDAP server hurts us,
39 * while returning too many attributes in ldb_search() doesn't)
42 struct ldb_map_context;
44 struct ldb_map_attribute
46 const char *local_name; /* local name */
48 enum ldb_map_attr_type {
49 MAP_IGNORE, /* Ignore this local attribute. Doesn't exist remotely. */
50 MAP_KEEP, /* Keep as is. Same name locally and remotely. */
51 MAP_RENAME, /* Simply rename the attribute. Name changes, data is the same */
52 MAP_CONVERT, /* Rename + convert data */
53 MAP_GENERATE /* Use generate function for generating new name/data.
54 Used for generating attributes based on
55 multiple remote attributes. */
58 /* if set, will be called for expressions that contain this attribute */
59 struct ldb_parse_tree *(*convert_operator) (struct ldb_map_context *, TALLOC_CTX *ctx, const struct ldb_parse_tree *);
63 const char *remote_name;
67 const char *remote_name;
68 struct ldb_val (*convert_local) (struct ldb_module *, TALLOC_CTX *, const struct ldb_val *);
70 /* an entry can have convert_remote set to NULL, as long as there as an entry with the same local_name
71 * that is non-NULL before it. */
72 struct ldb_val (*convert_remote) (struct ldb_module *, TALLOC_CTX *, const struct ldb_val *);
76 /* Generate the local attribute from remote message */
77 struct ldb_message_element *(*generate_local) (
81 const struct ldb_message *remote);
83 /* Update remote message with information from local message */
84 void (*generate_remote) (
86 const char *local_attr,
87 const struct ldb_message *local,
88 struct ldb_message *remote_mp,
89 struct ldb_message *remote_fb);
91 /* Name(s) for this attribute on the remote server. This is an array since
92 * one local attribute's data can be split up into several attributes
94 #define LDB_MAP_MAX_REMOTE_NAMES 10
95 const char *remote_names[LDB_MAP_MAX_REMOTE_NAMES];
100 #define LDB_MAP_MAX_SUBCLASSES 10
101 #define LDB_MAP_MAX_MUSTS 10
102 #define LDB_MAP_MAX_MAYS 50
103 struct ldb_map_objectclass
105 const char *local_name;
106 const char *remote_name;
107 const char *base_classes[LDB_MAP_MAX_SUBCLASSES];
108 const char *musts[LDB_MAP_MAX_MUSTS];
109 const char *mays[LDB_MAP_MAX_MAYS];
112 struct ldb_map_context
114 struct ldb_map_attribute *attribute_maps;
115 /* NOTE: Always declare base classes first here */
116 const struct ldb_map_objectclass *objectclass_maps;
117 struct ldb_context *mapped_ldb;
120 #endif /* __LDB_MAP_H__ */