2 ldb database library - Samba3 SAM compatibility 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
26 #include "ldb/ldb_map/ldb_map.h"
27 #include "ldb/include/ldb.h"
28 #include "ldb/include/ldb_private.h"
32 * sambaSIDList -> member (special!)
33 * sambaDomainName -> name
39 * sambaAcctFlags -> systemFlags ?
40 * sambaPasswordHistory -> ntPwdHistory*/
48 * sambaAlgorithmicRidBase
59 * sambaUserWorkstations
63 static struct ldb_message_element *convert_sid_rid(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
65 struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
68 printf("Converting SID TO RID *\n");
70 ret->flags = el->flags;
71 ret->name = talloc_strdup(ret, remote_attr);
72 ret->num_values = el->num_values;
73 ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
75 for (i = 0; i < ret->num_values; i++) {
76 ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
82 static struct ldb_message_element *convert_rid_sid(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
84 struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
87 printf("Converting RID TO SID *\n");
89 ret->flags = el->flags;
90 ret->name = talloc_strdup(ret, remote_attr);
91 ret->num_values = el->num_values;
92 ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
94 for (i = 0; i < ret->num_values; i++) {
95 ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
101 static struct ldb_message_element *convert_unix_id2name(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
104 struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
106 printf("Converting UNIX ID to name\n");
108 ret->flags = el->flags;
109 ret->name = talloc_strdup(ret, remote_attr);
110 ret->num_values = el->num_values;
111 ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
113 for (i = 0; i < ret->num_values; i++) {
114 ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
120 static struct ldb_message_element *convert_unix_name2id(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
122 struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
125 printf("Converting UNIX name to ID\n");
127 ret->flags = el->flags;
128 ret->name = talloc_strdup(ret, remote_attr);
129 ret->num_values = el->num_values;
130 ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
132 for (i = 0; i < ret->num_values; i++) {
133 ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
139 const struct ldb_map_objectclass samba3_objectclasses[] = {
140 { "group", "sambaGroupMapping" },
141 { "user", "sambaSAMAccount" },
142 { "domain", "sambaDomain" },
145 const struct ldb_map_attribute samba3_attributes[] =
147 /* sambaNextRid -> nextRid */
149 .local_name = "nextRid",
151 .u.rename.remote_name = "sambaNextRid",
154 /* sambaBadPasswordTime -> badPasswordtime*/
156 .local_name = "badPasswordTime",
158 .u.rename.remote_name = "sambaBadPasswordTime",
161 /* sambaLMPassword -> lmPwdHash*/
163 .local_name = "lmPwdHash",
165 .u.rename.remote_name = "sambaLMPassword",
168 /* sambaGroupType -> groupType */
170 .local_name = "groupType",
172 .u.rename.remote_name = "sambaGroupType",
175 /* sambaNTPassword -> ntPwdHash*/
177 .local_name = "badPwdCount",
179 .u.rename.remote_name = "sambaNTPassword",
182 /* sambaPrimaryGroupSID -> primaryGroupID */
184 .local_name = "primaryGroupID",
186 .u.convert.remote_name = "sambaPrimaryGroupSID",
187 .u.convert.convert_local = convert_rid_sid,
188 .u.convert.convert_remote = convert_sid_rid,
191 /* sambaBadPasswordCount -> badPwdCount */
193 .local_name = "badPwdCount",
195 .u.rename.remote_name = "sambaBadPasswordCount",
198 /* sambaLogonTime -> lastLogon*/
200 .local_name = "lastLogon",
202 .u.rename.remote_name = "sambaLogonTime",
205 /* sambaLogoffTime -> lastLogoff*/
207 .local_name = "lastLogoff",
209 .u.rename.remote_name = "sambaLogoffTime",
212 /* gidNumber -> unixName */
214 .local_name = "unixName",
216 .u.convert.remote_name = "gidNumber",
217 .u.convert.convert_local = convert_unix_name2id,
218 .u.convert.convert_remote = convert_unix_id2name,
221 /* uid -> unixName */
223 .local_name = "unixName",
225 .u.convert.remote_name = "uid",
226 .u.convert.convert_local = convert_unix_name2id,
227 .u.convert.convert_remote = convert_unix_id2name,
230 /* displayName -> name */
232 .local_name = "name",
234 .u.rename.remote_name = "displayName",
245 .local_name = "description",
249 /* sambaSID -> objectSid*/
251 .local_name = "objectSid",
253 .u.rename.remote_name = "sambaSID",
256 /* sambaPwdLastSet -> pwdLastSet*/
258 .local_name = "pwdLastSet",
260 .u.rename.remote_name = "sambaPwdLastSet",
264 /* the init function */
265 #ifdef HAVE_DLOPEN_DISABLED
266 struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
268 struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, const char *options[])
271 return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, options);