r9793: Be more verbose, check for errors in upgrade script.
[samba.git] / source / dsdb / samdb / ldb_modules / samba3sam.c
1 /* 
2    ldb database library - Samba3 SAM compatibility backend
3
4    Copyright (C) Jelmer Vernooij 2005
5 */
6
7 #include "includes.h"
8 #include "ldb/modules/ldb_map.h"
9 #include "ldb/include/ldb.h"
10 #include "ldb/include/ldb_private.h"
11
12 /* FIXME: 
13  * sambaSID -> member  (dn!)
14  * sambaSIDList -> member (dn!) 
15  * sambaDomainName -> name 
16  * sambaTrustPassword 
17  * sambaUnixIdPool 
18  * sambaIdmapEntry 
19  * sambaAccountPolicy 
20  * sambaSidEntry 
21  * sambaAcctFlags -> systemFlags ?
22  * sambaPasswordHistory  -> ntPwdHistory*/
23
24 /* Not necessary:
25  * sambaConfig
26  * sambaShare
27  * sambaConfigOption 
28  * sambaNextGroupRid
29  * sambaNextUserRid
30  * sambaAlgorithmicRidBase
31  */
32
33 /* Not in Samba4: 
34  * sambaKickoffTime
35  * sambaPwdCanChange
36  * sambaPwdMustChange
37  * sambaHomePath
38  * sambaHomeDrive
39  * sambaLogonScript
40  * sambaProfilePath
41  * sambaUserWorkstations
42  * sambaMungedDial
43  * sambaLogonHours */
44
45 /* In Samba4 but not in Samba3:
46 */
47
48 static struct ldb_val convert_sid_rid(struct ldb_map_context *map, TALLOC_CTX *ctx, const struct ldb_val *val)
49 {
50         printf("Converting SID TO RID *\n");
51
52         /* FIXME */
53
54         return ldb_val_dup(ctx, val);
55 }
56
57 static struct ldb_val convert_rid_sid(struct ldb_map_context *map, TALLOC_CTX *ctx, const struct ldb_val *val)
58 {
59         printf("Converting RID TO SID *\n");
60
61         /* FIXME */
62
63         return ldb_val_dup(ctx, val);
64 }
65
66 static struct ldb_val convert_unix_id2name(struct ldb_map_context *map, TALLOC_CTX *ctx, const struct ldb_val *val)
67 {
68         printf("Converting UNIX ID to name\n");
69
70         /* FIXME */
71
72         return ldb_val_dup(ctx, val);
73 }
74
75 static struct ldb_val convert_unix_name2id(struct ldb_map_context *map, TALLOC_CTX *ctx, const struct ldb_val *val)
76 {
77         printf("Converting UNIX name to ID\n");
78
79         /* FIXME */
80
81         return ldb_val_dup(ctx, val);
82 }
83
84 const struct ldb_map_objectclass samba3_objectclasses[] = {
85         { "group", "sambaGroupMapping" },
86         { "user", "sambaSAMAccount" },
87         { "domain", "sambaDomain" },
88         { NULL, NULL }
89 };
90
91 const struct ldb_map_attribute samba3_attributes[] = 
92 {
93         /* sambaNextRid -> nextRid */
94         {
95                 .local_name = "nextRid",
96                 .type = MAP_RENAME,
97                 .u.rename.remote_name = "sambaNextRid",
98         },
99
100         /* sambaBadPasswordTime -> badPasswordtime*/
101         {
102                 .local_name = "badPasswordTime",
103                 .type = MAP_RENAME,
104                 .u.rename.remote_name = "sambaBadPasswordTime",
105         },
106
107         /* sambaLMPassword -> lmPwdHash*/
108         {
109                 .local_name = "lmPwdHash",
110                 .type = MAP_RENAME,
111                 .u.rename.remote_name = "sambaLMPassword",
112         },
113
114         /* sambaGroupType -> groupType */
115         {
116                 .local_name = "groupType",
117                 .type = MAP_RENAME,
118                 .u.rename.remote_name = "sambaGroupType",
119         },
120
121         /* sambaNTPassword -> ntPwdHash*/
122         {
123                 .local_name = "badPwdCount",
124                 .type = MAP_RENAME,
125                 .u.rename.remote_name = "sambaNTPassword",
126         },
127
128         /* sambaPrimaryGroupSID -> primaryGroupID */
129         {
130                 .local_name = "primaryGroupID",
131                 .type = MAP_CONVERT,
132                 .u.convert.remote_name = "sambaPrimaryGroupSID",
133                 .u.convert.convert_local = convert_rid_sid,
134                 .u.convert.convert_remote = convert_sid_rid, 
135         },
136
137         /* sambaBadPasswordCount -> badPwdCount */
138         {
139                 .local_name = "badPwdCount",
140                 .type = MAP_RENAME,
141                 .u.rename.remote_name = "sambaBadPasswordCount",
142         },
143
144         /* sambaLogonTime -> lastLogon*/
145         {
146                 .local_name = "lastLogon",
147                 .type = MAP_RENAME,
148                 .u.rename.remote_name = "sambaLogonTime",
149         },
150
151         /* sambaLogoffTime -> lastLogoff*/
152         {
153                 .local_name = "lastLogoff",
154                 .type = MAP_RENAME,
155                 .u.rename.remote_name = "sambaLogoffTime",
156         },
157
158         /* gidNumber -> unixName */
159         {
160                 .local_name = "unixName",
161                 .type = MAP_CONVERT,
162                 .u.convert.remote_name = "gidNumber",
163                 .u.convert.convert_local = convert_unix_name2id,
164                 .u.convert.convert_remote = convert_unix_id2name, 
165         },
166
167         /* uid -> unixName */
168         {
169                 .local_name = "unixName",
170                 .type = MAP_RENAME,
171                 .u.convert.remote_name = "uid",
172         },
173
174         /* displayName -> name */
175         {
176                 .local_name = "name",
177                 .type = MAP_RENAME,
178                 .u.rename.remote_name = "displayName",
179         },
180
181         /* cn */
182         {
183                 .local_name = "cn",
184                 .type = MAP_KEEP,
185         },
186
187         /* sAMAccountName -> cn */
188         {
189                 .local_name = "sAMAccountName",
190                 .type = MAP_RENAME,
191                 .u.rename.remote_name = "uid",
192         },
193
194         /* objectCategory */
195         {
196                 .local_name = "objectCategory",
197                 .type = MAP_IGNORE,
198         },
199
200         /* objectGUID */
201         {
202                 .local_name = "objectGUID",
203                 .type = MAP_IGNORE,
204         },
205
206         /* objectVersion */
207         {
208                 .local_name = "objectVersion",
209                 .type = MAP_IGNORE,
210         },
211
212         /* codePage */
213         { 
214                 .local_name = "codePage",
215                 .type = MAP_IGNORE,
216         },
217
218         /* dNSHostName */
219         {
220                 .local_name = "dNSHostName",
221                 .type = MAP_IGNORE,
222         },
223
224
225         /* dnsDomain */
226         {
227                 .local_name = "dnsDomain",
228                 .type = MAP_IGNORE,
229         },
230
231         /* dnsRoot */
232         {
233                 .local_name = "dnsRoot",
234                 .type = MAP_IGNORE,
235         },
236
237         /* countryCode */
238         {
239                 .local_name = "countryCode",
240                 .type = MAP_IGNORE,
241         },
242
243         /* nTMixedDomain */
244         { 
245                 .local_name = "nTMixedDomain",
246                 .type = MAP_IGNORE,
247         },
248
249         /* operatingSystem */
250         { 
251                 .local_name = "operatingSystem",
252                 .type = MAP_IGNORE,
253         },
254
255         /* operatingSystemVersion */
256         {
257                 .local_name = "operatingSystemVersion",
258                 .type = MAP_IGNORE,
259         },
260
261
262         /* servicePrincipalName */
263         {
264                 .local_name = "servicePrincipalName",
265                 .type = MAP_IGNORE,
266         },
267
268         /* msDS-Behavior-Version */
269         {
270                 .local_name = "msDS-Behavior-Version",
271                 .type = MAP_IGNORE,
272         },
273
274         /* msDS-KeyVersionNumber */
275         {
276                 .local_name = "msDS-KeyVersionNumber",
277                 .type = MAP_IGNORE,
278         },
279
280         /* msDs-masteredBy */
281         {
282                 .local_name = "msDs-masteredBy",
283                 .type = MAP_IGNORE,
284         },
285
286         /* ou */
287         {
288                 .local_name = "ou",
289                 .type = MAP_KEEP,
290         },
291
292         /* dc */
293         {
294                 .local_name = "dc",
295                 .type = MAP_KEEP,
296         },
297
298         /* description */
299         {
300                 .local_name = "description",
301                 .type = MAP_KEEP,
302         },
303
304         /* sambaSID -> objectSid*/
305         {
306                 .local_name = "objectSid",
307                 .type = MAP_RENAME,
308                 .u.rename.remote_name = "sambaSID", 
309         },
310
311         /* sambaPwdLastSet -> pwdLastSet */
312         {
313                 .local_name = "pwdLastSet",
314                 .type = MAP_RENAME,
315                 .u.rename.remote_name = "sambaPwdLastSet",
316         },      
317
318         /* accountExpires */
319         {
320                 .local_name = "accountExpires", 
321                 .type = MAP_IGNORE,
322         },
323
324         /* adminCount */
325         {
326                 .local_name = "adminCount",
327                 .type = MAP_IGNORE,
328         },
329
330         /* canonicalName */
331         {
332                 .local_name = "canonicalName",
333                 .type = MAP_IGNORE,
334         },
335
336         /* createTimestamp */
337         {
338                 .local_name = "createTimestamp",
339                 .type = MAP_IGNORE,
340         },
341         
342         /* creationTime */
343         {
344                 .local_name = "creationTime",
345                 .type = MAP_IGNORE,
346         },
347         
348         /* dMDLocation */
349         {
350                 .local_name = "dMDLocation",
351                 .type = MAP_IGNORE,
352         },
353         
354         /* fSMORoleOwner */
355         {
356                 .local_name = "fSMORoleOwner",
357                 .type = MAP_IGNORE,
358         },
359         
360         /* forceLogoff */
361         {
362                 .local_name = "forceLogoff",
363                 .type = MAP_IGNORE,
364         },
365         
366         /* instanceType */
367         {
368                 .local_name = "instanceType",
369                 .type = MAP_IGNORE,
370         },
371         
372         /* invocationId */
373         {
374                 .local_name = "invocationId",
375                 .type = MAP_IGNORE,
376         },
377         
378         /* isCriticalSystemObject */
379         {
380                 .local_name = "isCriticalSystemObject",
381                 .type = MAP_IGNORE,
382         },
383         
384         /* localPolicyFlags */
385         {
386                 .local_name = "localPolicyFlags",
387                 .type = MAP_IGNORE,
388         },
389         
390         /* lockOutObservationWindow */
391         {
392                 .local_name = "lockOutObservationWindow",
393                 .type = MAP_IGNORE,
394         },
395
396         /* lockoutDuration */
397         {
398                 .local_name = "lockoutDuration",
399                 .type = MAP_IGNORE,
400         },
401
402         /* lockoutThreshold */
403         {
404                 .local_name = "lockoutThreshold",
405                 .type = MAP_IGNORE,
406         },
407
408         /* logonCount */
409         {
410                 .local_name = "logonCount",
411                 .type = MAP_IGNORE,
412         },
413
414         /* masteredBy */
415         {
416                 .local_name = "masteredBy",
417                 .type = MAP_IGNORE,
418         },
419
420         /* maxPwdAge */
421         {
422                 .local_name = "maxPwdAge",
423                 .type = MAP_IGNORE,
424         },
425
426         /* member */
427         {
428                 .local_name = "member",
429                 .type = MAP_IGNORE,
430         },
431
432         /* memberOf */
433         {
434                 .local_name = "memberOf",
435                 .type = MAP_IGNORE,
436         },
437
438         /* minPwdAge */
439         {
440                 .local_name = "minPwdAge",
441                 .type = MAP_IGNORE,
442         },
443
444         /* minPwdLength */
445         {
446                 .local_name = "minPwdLength",
447                 .type = MAP_IGNORE,
448         },
449
450         /* modifiedCount */
451         {
452                 .local_name = "modifiedCount",
453                 .type = MAP_IGNORE,
454         },
455
456         /* modifiedCountAtLastProm */
457         {
458                 .local_name = "modifiedCountAtLastProm",
459                 .type = MAP_IGNORE,
460         },
461
462         /* modifyTimestamp */
463         {
464                 .local_name = "modifyTimestamp",
465                 .type = MAP_IGNORE,
466         },
467
468         /* nCName */
469         {
470                 .local_name = "nCName",
471                 .type = MAP_IGNORE,
472         },
473
474         /* nETBIOSName */
475         {
476                 .local_name = "nETBIOSName",
477                 .type = MAP_IGNORE,
478         },
479
480         /* oEMInformation */
481         {
482                 .local_name = "oEMInformation",
483                 .type = MAP_IGNORE,
484         },
485
486         /* privilege */
487         {
488                 .local_name = "privilege",
489                 .type = MAP_IGNORE,
490         },
491
492         /* pwdHistoryLength */
493         {
494                 .local_name = "pwdHistoryLength",
495                 .type = MAP_IGNORE,
496         },
497
498         /* pwdProperties */
499         {
500                 .local_name = "pwdProperties",
501                 .type = MAP_IGNORE,
502         },
503
504         /* rIDAvailablePool */
505         {
506                 .local_name = "rIDAvailablePool",
507                 .type = MAP_IGNORE,
508         },
509
510         /* revision */
511         {
512                 .local_name = "revision",
513                 .type = MAP_IGNORE,
514         },
515
516         /* ridManagerReference */
517         {
518                 .local_name = "ridManagerReference",
519                 .type = MAP_IGNORE,
520         },
521
522         /* sAMAccountType */
523         {
524                 .local_name = "sAMAccountType",
525                 .type = MAP_IGNORE,
526         },
527
528         /* sPNMappings */
529         {
530                 .local_name = "sPNMappings",
531                 .type = MAP_IGNORE,
532         },
533
534         /* serverReference */
535         {
536                 .local_name = "serverReference",
537                 .type = MAP_IGNORE,
538         },
539
540         /* serverState */
541         {
542                 .local_name = "serverState",
543                 .type = MAP_IGNORE,
544         },
545
546         /* showInAdvancedViewOnly */
547         {
548                 .local_name = "showInAdvancedViewOnly",
549                 .type = MAP_IGNORE,
550         },
551
552         /* subRefs */
553         {
554                 .local_name = "subRefs",
555                 .type = MAP_IGNORE,
556         },
557
558         /* systemFlags */
559         {
560                 .local_name = "systemFlags",
561                 .type = MAP_IGNORE,
562         },
563
564         /* uASCompat */
565         {
566                 .local_name = "uASCompat",
567                 .type = MAP_IGNORE,
568         },
569
570         /* uSNChanged */
571         {
572                 .local_name = "uSNChanged",
573                 .type = MAP_IGNORE,
574         },
575
576         /* uSNCreated */
577         {
578                 .local_name = "uSNCreated",
579                 .type = MAP_IGNORE,
580         },
581
582         /* unicodePwd */
583         {
584                 .local_name = "unicodePwd",
585                 .type = MAP_IGNORE,
586         },
587
588         /* userAccountControl */
589         {
590                 .local_name = "userAccountControl",
591                 .type = MAP_IGNORE,
592         },
593
594         /* whenChanged */
595         {
596                 .local_name = "whenChanged",
597                 .type = MAP_IGNORE,
598         },
599
600         /* whenCreated */
601         {
602                 .local_name = "whenCreated",
603                 .type = MAP_IGNORE,
604         },
605
606         {
607                 .local_name = NULL,
608         }
609 };
610
611         /* the init function */
612 #ifdef HAVE_DLOPEN_DISABLED
613 struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
614 #else
615 struct ldb_module *ldb_samba3sam_module_init(struct ldb_context *ldb, const char *options[])
616 #endif
617 {
618         return ldb_map_init(ldb, samba3_attributes, samba3_objectclasses, "samba3sam");
619 }