2 ldb database library - map backend
4 Copyright (C) Jelmer Vernooij 2005
6 ** NOTE! The following LGPL license applies to the ldb
7 ** library. This does NOT imply that all of Samba is released
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 /* ldb_map is a skeleton LDB module that can be used for any other modules
29 * that need to map attributes.
31 * The term 'remote' in this header refers to the connection where the
32 * original schema is used on while 'local' means the local connection
33 * that any upper layers will use.
35 * All local attributes will have to have a definition. Not all remote
36 * attributes need a definition as LDB is a lot less stricter then LDAP
37 * (in other words, sending unknown attributes to an LDAP server hurts us,
38 * returning too much attributes in ldb_search() doesn't)
41 struct ldb_map_context;
43 struct ldb_map_attribute
45 const char *local_name; /* local name */
47 enum ldb_map_attr_type {
48 MAP_IGNORE, /* Ignore this local attribute. Doesn't exist remotely. */
49 MAP_KEEP, /* Keep as is. Same name locally and remotely. */
50 MAP_RENAME, /* Simply rename the attribute. Name changes, data is the same */
51 MAP_CONVERT, /* Rename + convert data */
52 MAP_GENERATE /* Use generate function for generating new name/data.
53 Used for generating attributes based on
54 multiple remote attributes. */
57 /* if set, will be called for expressions that contain this attribute */
58 struct ldb_parse_tree *(*convert_operator) (struct ldb_map_context *, TALLOC_CTX *ctx, const struct ldb_parse_tree *);
62 const char *remote_name;
66 const char *remote_name;
67 struct ldb_val (*convert_local) (struct ldb_module *, TALLOC_CTX *, const struct ldb_val *);
68 struct ldb_val (*convert_remote) (struct ldb_module *, TALLOC_CTX *, const struct ldb_val *);
72 /* Generate the local attribute from remote message */
73 struct ldb_message_element *(*generate_local) (
77 const struct ldb_message *remote);
79 /* Update remote message with information from local message */
80 void (*generate_remote) (
82 const char *local_attr,
83 const struct ldb_message *local,
84 struct ldb_message *remote_mp,
85 struct ldb_message *remote_fb);
87 /* Name(s) for this attribute on the remote server. This is an array since
88 * one local attribute's data can be split up into several attributes
90 #define LDB_MAP_MAX_REMOTE_NAMES 10
91 const char *remote_names[LDB_MAP_MAX_REMOTE_NAMES];
96 #define LDB_MAP_MAX_SUBCLASSES 10
97 #define LDB_MAP_MAX_MUSTS 10
98 #define LDB_MAP_MAX_MAYS 50
99 struct ldb_map_objectclass
101 const char *local_name;
102 const char *remote_name;
103 const char *base_classes[LDB_MAP_MAX_SUBCLASSES];
104 const char *musts[LDB_MAP_MAX_MUSTS];
105 const char *mays[LDB_MAP_MAX_MAYS];
108 struct ldb_map_context
110 struct ldb_map_attribute *attribute_maps;
111 /* NOTE: Always declare base classes first here */
112 const struct ldb_map_objectclass *objectclass_maps;
113 struct ldb_context *mapped_ldb;
116 #endif /* __LDB_MAP_H__ */