1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#!/usr/bin/env smbscript
libinclude("base.js");
var mypath = substr(ARGV[0], 0, -strlen("samba3sam"));
var sys = sys_init();
var s3url;
var s3 = ldb_init();
var ok;
if (ARGV.length == 2) {
s3url = ARGV[1];
ok = s3.connect(s3url);
assert(ok);
} else {
s3url = "tdb://samba3.ldb";
sys.unlink("samba3.ldb");
println("Adding samba3 LDIF...");
var s3 = ldb_init();
ok = s3.connect(s3url);
assert(ok);
var ldif = sys.file_load(mypath + "../../testdata/samba3/samba3.ldif");
assert(ldif != undefined);
ok = s3.add(ldif);
assert(ok);
}
println("Initial samba4 LDIF...");
var s4 = ldb_init();
sys.unlink("samba4.ldb");
ok = s4.connect("tdb://samba4.ldb");
assert(ok);
var ldif = sys.file_load(mypath + "../../source/setup/provision_init.ldif");
assert(ldif != undefined);
ok = s4.add(ldif);
assert(ok);
ok = s4.add(sprintf("dn: @MAP=samba3sam
@MAP_URL: %s", s3url));
assert(ok);
ok = s4.modify("
dn: @MODULES
replace: @LIST
@LIST: samldb,timestamps,objectguid,rdn_name,samba3sam");
assert(ok);
println("Reconnecting to LDB database");
s4 = ldb_init();
ok = s4.connect("tdb://samba4.ldb");
assert(ok);
msg = s4.search("(ou=Users)");
assert(msg.length == 1);
assert(msg['mappedFromDn'] == msg['dn']);
println("Looking up by non-mapped attribute");
msg = s4.search("(cn=Administrator)");
assert(msg.length == 1);
println("Looking up by mapped attribute");
msg = s4.search("(name=Backup Operators)");
assert(msg.length == 1);
println("Looking up by old name of renamed attribute");
msg = s4.search("(displayName=Backup Operators)");
assert(msg.length == 1);
println("Adding a record");
ok = s4.add("
dn: cn=Foo,dc=idealx,dc=org
unixName: root
lastLogon: 20000
cn: Foo
showInAdvancedViewOnly: TRUE
");
assert(ok);
println("Checking for existance of record");
msg = s4.search("(cn=Foo)", new Array('unixName','lastLogon','cn','showInAdvancedViewOnly'));
assert(msg.length == 1);
println("Checking for persistence of non-mappable attribute");
msg = s4.search("(cn=Foo)", new Array('showInAdvancedViewOnly'));
assert(msg.length == 1);
println("Adding record with mapped attribute in dn");
ok = s4.add("
dn: unixName=nobody,dc=idealx,dc=org
unixName: nobody
cn: Niemand
");
assert(ok);
println("Checking for existance of record (mapped)");
msg = s4.search("(unixName=nobody)", new Array('unixName','cn','dn'));
assert(msg.length == 1);
|