1 #!/usr/bin/env smbscript
3 (C) Jelmer Vernooij <jelmer@samba.org> 2005
4 (C) Martin Kuehl <mkhl@samba.org> 2006
5 Published under the GNU GPL
6 Sponsored by Google Summer of Code
10 var options = GetOptions(ARGV, "POPT_AUTOHELP", "POPT_COMMON_SAMBA");
11 if (options == undefined) {
12 println("Failed to parse options");
16 libinclude("base.js");
18 if (options.ARGV.length != 2) {
19 println("Usage: samba3sam.js <TESTDIR> <DATADIR>");
23 var prefix = options.ARGV[0];
24 var datadir = options.ARGV[1];
26 function setup_data(obj, ldif)
28 assert(ldif != undefined);
29 ldif = substitute_var(ldif, obj);
30 assert(ldif != undefined);
31 var ok = obj.db.add(ldif);
32 assert(ok.error == 0);
35 function setup_modules(ldb, s3, s4, ldif)
37 assert(ldif != undefined);
38 ldif = substitute_var(ldif, s4);
39 assert(ldif != undefined);
40 var ok = ldb.add(ldif);
41 assert(ok.error == 0);
45 @FROM: " + s4.BASEDN + "
46 @TO: sambaDomainName=TESTS," + s3.BASEDN + "
49 @LIST: rootdse,paged_results,server_sort,extended_dn,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,partition
52 partition: " + s4.BASEDN + ":" + s4.url + "
53 partition: " + s3.BASEDN + ":" + s3.url + "
54 replicateEntries: @SUBCLASSES
55 replicateEntries: @ATTRIBUTES
56 replicateEntries: @INDEXLIST
58 var ok = ldb.add(ldif);
59 assert(ok.error == 0);
62 function test_s3sam_search(ldb)
64 println("Looking up by non-mapped attribute");
65 var msg = ldb.search("(cn=Administrator)");
66 assert(msg.error == 0);
67 assert(msg.msgs.length == 1);
68 assert(msg.msgs[0].cn == "Administrator");
70 println("Looking up by mapped attribute");
71 var msg = ldb.search("(name=Backup Operators)");
72 assert(msg.error == 0);
73 assert(msg.msgs.length == 1);
74 assert(msg.msgs[0].name == "Backup Operators");
76 println("Looking up by old name of renamed attribute");
77 var msg = ldb.search("(displayName=Backup Operators)");
78 assert(msg.msgs.length == 0);
80 println("Looking up mapped entry containing SID");
81 var msg = ldb.search("(cn=Replicator)");
82 assert(msg.error == 0);
83 assert(msg.msgs.length == 1);
84 println(msg.msgs[0].dn);
85 assert(msg.msgs[0].dn == "cn=Replicator,ou=Groups,dc=vernstok,dc=nl");
86 assert(msg.msgs[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552");
88 println("Checking mapping of objectClass");
89 var oc = msg.msgs[0].objectClass;
90 assert(oc != undefined);
92 assert(oc[i] == "posixGroup" || oc[i] == "group");
95 println("Looking up by objectClass");
96 var msg = ldb.search("(|(objectClass=user)(cn=Administrator))");
97 assert(msg.error == 0);
98 assert(msg.msgs.length == 2);
99 for (var i = 0; i < msg.msgs.length; i++) {
100 assert((msg.msgs[i].dn == "unixName=Administrator,ou=Users,dc=vernstok,dc=nl") ||
101 (msg.msgs[i].dn == "unixName=nobody,ou=Users,dc=vernstok,dc=nl"));
105 function test_s3sam_modify(ldb, s3)
108 println("Adding a record that will be fallbacked");
114 showInAdvancedViewOnly: TRUE
118 assert(ok.error == 0);
121 println("Checking for existence of record (local)");
122 /* TODO: This record must be searched in the local database, which is currently only supported for base searches
123 * msg = ldb.search("(cn=Foo)", new Array('foo','blah','cn','showInAdvancedViewOnly'));
124 * TODO: Actually, this version should work as well but doesn't...
127 var attrs = new Array('foo','blah','cn','showInAdvancedViewOnly');
128 msg = ldb.search("(cn=Foo)", "cn=Foo", ldb.LDB_SCOPE_BASE, attrs);
129 assert(msg.error == 0);
130 assert(msg.msgs.length == 1);
131 assert(msg.msgs[0].showInAdvancedViewOnly == "TRUE");
132 assert(msg.msgs[0].foo == "bar");
133 assert(msg.msgs[0].blah == "Blie");
135 println("Adding record that will be mapped");
137 dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
140 sambaUnicodePwd: geheim
145 assert(ok.error == 0);
147 assert(ok.error == 0);
149 println("Checking for existence of record (remote)");
150 msg = ldb.search("(unixName=bin)", new Array('unixName','cn','dn', 'sambaUnicodePwd'));
151 assert(msg.error == 0);
152 assert(msg.msgs.length == 1);
153 assert(msg.msgs[0].cn == "Niemand");
154 assert(msg.msgs[0].sambaUnicodePwd == "geheim");
156 println("Checking for existence of record (local && remote)");
157 msg = ldb.search("(&(unixName=bin)(sambaUnicodePwd=geheim))", new Array('unixName','cn','dn', 'sambaUnicodePwd'));
158 assert(msg.error == 0);
159 assert(msg.msgs.length == 1); // TODO: should check with more records
160 assert(msg.msgs[0].cn == "Niemand");
161 assert(msg.msgs[0].unixName == "bin");
162 assert(msg.msgs[0].sambaUnicodePwd == "geheim");
164 println("Checking for existence of record (local || remote)");
165 msg = ldb.search("(|(unixName=bin)(sambaUnicodePwd=geheim))", new Array('unixName','cn','dn', 'sambaUnicodePwd'));
166 println("got " + msg.msgs.length + " replies");
167 assert(msg.error == 0);
168 assert(msg.msgs.length == 1); // TODO: should check with more records
169 assert(msg.msgs[0].cn == "Niemand");
170 assert(msg.msgs[0].unixName == "bin" || msg.msgs[0].sambaUnicodePwd == "geheim");
172 println("Checking for data in destination database");
173 msg = s3.db.search("(cn=Niemand)");
174 assert(msg.error == 0);
175 assert(msg.msgs.length >= 1);
176 assert(msg.msgs[0].sambaSID == "S-1-5-21-4231626423-2410014848-2360679739-2001");
177 assert(msg.msgs[0].displayName == "Niemand");
179 println("Adding attribute...");
181 dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
188 assert(ok.error == 0);
190 assert(ok.error == 0);
192 println("Checking whether changes are still there...");
193 msg = ldb.search("(cn=Niemand)");
194 assert(msg.error == 0);
195 assert(msg.msgs.length >= 1);
196 assert(msg.msgs[0].cn == "Niemand");
197 assert(msg.msgs[0].description == "Blah");
199 println("Modifying attribute...");
201 dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
208 assert(ok.error == 0);
210 assert(ok.error == 0);
212 println("Checking whether changes are still there...");
213 msg = ldb.search("(cn=Niemand)");
214 assert(msg.error == 0);
215 assert(msg.msgs.length >= 1);
216 assert(msg.msgs[0].description == "Blie");
218 println("Deleting attribute...");
220 dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
226 assert(ok.error == 0);
228 assert(ok.error == 0);
230 println("Checking whether changes are no longer there...");
231 msg = ldb.search("(cn=Niemand)");
232 assert(msg.error == 0);
233 assert(msg.msgs.length >= 1);
234 assert(msg.msgs[0].description == undefined);
236 println("Renaming record...");
237 ok = ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", "cn=Niemand2,cn=Users,dc=vernstok,dc=nl");
238 assert(ok.error == 0);
240 println("Checking whether DN has changed...");
241 msg = ldb.search("(cn=Niemand2)");
242 assert(msg.error == 0);
243 assert(msg.msgs.length == 1);
244 assert(msg.msgs[0].dn == "cn=Niemand2,cn=Users,dc=vernstok,dc=nl");
246 println("Deleting record...");
247 ok = ldb.del("cn=Niemand2,cn=Users,dc=vernstok,dc=nl");
250 assert(ok.error == 0);
253 println("Checking whether record is gone...");
254 msg = ldb.search("(cn=Niemand2)");
255 assert(msg.error == 0);
256 assert(msg.msgs.length == 0);
259 function test_map_search(ldb, s3, s4)
261 println("Running search tests on mapped data");
268 dn: " + "sambaDomainName=TESTS," + s3.BASEDN + "
269 objectclass: sambaDomain
271 sambaSID: S-1-5-21-4231626423-2410014848-2360679739
273 sambaDomainName: TESTS"
274 ldif = substitute_var(ldif, s3);
275 assert(ldif != undefined);
276 var ok = s3.db.add(ldif);
277 assert(ok.error == 0);
279 printf("Add a set of split records");
281 dn: " + s4.dn("cn=X") + "
290 objectSid: S-1-5-21-4231626423-2410014848-2360679739-552
291 primaryGroupID: 1-5-21-4231626423-2410014848-2360679739-512
293 dn: " + s4.dn("cn=Y") + "
303 dn: " + s4.dn("cn=Z") + "
314 ldif = substitute_var(ldif, s4);
315 assert(ldif != undefined);
316 var ok = ldb.add(ldif);
319 assert(ok.error == 0);
322 println("Add a set of remote records");
325 dn: " + s3.dn("cn=A") + "
326 objectClass: posixAccount
329 sambaBadPasswordCount: x
332 sambaSID: S-1-5-21-4231626423-2410014848-2360679739-552
333 sambaPrimaryGroupSID: S-1-5-21-4231626423-2410014848-2360679739-512
335 dn: " + s3.dn("cn=B") + "
339 sambaBadPasswordCount: x
343 dn: " + s3.dn("cn=C") + "
347 sambaBadPasswordCount: y
351 ldif = substitute_var(ldif, s3);
352 assert(ldif != undefined);
353 var ok = s3.db.add(ldif);
354 assert(ok.error == 0);
356 println("Testing search by DN");
358 /* Search remote record by local DN */
360 attrs = new Array("dnsHostName", "lastLogon");
361 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
362 assert(res.error == 0);
363 assert(res.msgs.length == 1);
364 assert(res.msgs[0].dn == dn);
365 assert(res.msgs[0].dnsHostName == undefined);
366 assert(res.msgs[0].lastLogon == "x");
368 /* Search remote record by remote DN */
370 attrs = new Array("dnsHostName", "lastLogon", "sambaLogonTime");
371 res = s3.db.search("", dn, ldb.SCOPE_BASE, attrs);
372 assert(res.error == 0);
373 assert(res.msgs.length == 1);
374 assert(res.msgs[0].dn == dn);
375 assert(res.msgs[0].dnsHostName == undefined);
376 assert(res.msgs[0].lastLogon == undefined);
377 assert(res.msgs[0].sambaLogonTime == "x");
379 /* Search split record by local DN */
381 attrs = new Array("dnsHostName", "lastLogon");
382 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
383 assert(res.error == 0);
384 assert(res.msgs.length == 1);
385 assert(res.msgs[0].dn == dn);
386 assert(res.msgs[0].dnsHostName == "x");
387 assert(res.msgs[0].lastLogon == "x");
389 /* Search split record by remote DN */
391 attrs = new Array("dnsHostName", "lastLogon", "sambaLogonTime");
392 res = s3.db.search("", dn, ldb.SCOPE_BASE, attrs);
393 assert(res.error == 0);
394 assert(res.msgs.length == 1);
395 assert(res.msgs[0].dn == dn);
396 assert(res.msgs[0].dnsHostName == undefined);
397 assert(res.msgs[0].lastLogon == undefined);
398 assert(res.msgs[0].sambaLogonTime == "x");
400 println("Testing search by attribute");
402 /* Search by ignored attribute */
403 attrs = new Array("dnsHostName", "lastLogon");
404 res = ldb.search("(revision=x)", NULL, ldb. SCOPE_DEFAULT, attrs);
405 assert(res.error == 0);
406 assert(res.msgs.length == 2);
407 assert(res.msgs[0].dn == s4.dn("cn=Y"));
408 assert(res.msgs[0].dnsHostName == "y");
409 assert(res.msgs[0].lastLogon == "y");
410 assert(res.msgs[1].dn == s4.dn("cn=X"));
411 assert(res.msgs[1].dnsHostName == "x");
412 assert(res.msgs[1].lastLogon == "x");
414 /* Search by kept attribute */
415 attrs = new Array("dnsHostName", "lastLogon");
416 res = ldb.search("(description=y)", NULL, ldb. SCOPE_DEFAULT, attrs);
417 assert(res.error == 0);
418 assert(res.msgs.length == 2);
419 assert(res.msgs[0].dn == s4.dn("cn=Z"));
420 assert(res.msgs[0].dnsHostName == "z");
421 assert(res.msgs[0].lastLogon == "z");
422 assert(res.msgs[1].dn == s4.dn("cn=C"));
423 assert(res.msgs[1].dnsHostName == undefined);
424 assert(res.msgs[1].lastLogon == "z");
426 /* Search by renamed attribute */
427 attrs = new Array("dnsHostName", "lastLogon");
428 res = ldb.search("(badPwdCount=x)", NULL, ldb. SCOPE_DEFAULT, attrs);
429 assert(res.error == 0);
430 assert(res.msgs.length == 2);
431 assert(res.msgs[0].dn == s4.dn("cn=B"));
432 assert(res.msgs[0].dnsHostName == undefined);
433 assert(res.msgs[0].lastLogon == "y");
434 assert(res.msgs[1].dn == s4.dn("cn=A"));
435 assert(res.msgs[1].dnsHostName == undefined);
436 assert(res.msgs[1].lastLogon == "x");
438 /* Search by converted attribute */
439 attrs = new Array("dnsHostName", "lastLogon", "objectSid");
441 Using the SID directly in the parse tree leads to conversion
442 errors, letting the search fail with no results.
443 res = ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-552)", NULL, ldb. SCOPE_DEFAULT, attrs);
445 res = ldb.search("(objectSid=*)", NULL, ldb. SCOPE_DEFAULT, attrs);
446 assert(res.error == 0);
447 assert(res.msgs.length == 3);
448 assert(res.msgs[0].dn == s4.dn("cn=X"));
449 assert(res.msgs[0].dnsHostName == "x");
450 assert(res.msgs[0].lastLogon == "x");
451 assert(res.msgs[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552");
452 assert(res.msgs[1].dn == s4.dn("cn=A"));
453 assert(res.msgs[1].dnsHostName == undefined);
454 assert(res.msgs[1].lastLogon == "x");
455 assert(res.msgs[1].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552");
457 /* Search by generated attribute */
458 /* In most cases, this even works when the mapping is missing
459 * a `convert_operator' by enumerating the remote db. */
460 attrs = new Array("dnsHostName", "lastLogon", "primaryGroupID");
461 res = ldb.search("(primaryGroupID=512)", NULL, ldb. SCOPE_DEFAULT, attrs);
462 assert(res.error == 0);
463 assert(res.msgs.length == 1);
464 assert(res.msgs[0].dn == s4.dn("cn=A"));
465 assert(res.msgs[0].dnsHostName == undefined);
466 assert(res.msgs[0].lastLogon == "x");
467 assert(res.msgs[0].primaryGroupID == "512");
469 /* TODO: There should actually be two results, A and X. The
470 * primaryGroupID of X seems to get corrupted somewhere, and the
471 * objectSid isn't available during the generation of remote (!) data,
472 * which can be observed with the following search. Also note that Xs
473 * objectSid seems to be fine in the previous search for objectSid... */
475 res = ldb.search("(primaryGroupID=*)", NULL, ldb. SCOPE_DEFAULT, attrs);
476 println(res.msgs.length + " results found");
477 for (i=0;i<res.msgs.length;i++) {
478 for (obj in res.msgs[i]) {
479 println(obj + ": " + res.msgs[i][obj]);
485 /* Search by remote name of renamed attribute */
486 attrs = new Array("dnsHostName", "lastLogon");
487 res = ldb.search("(sambaBadPasswordCount=*)", "", ldb. SCOPE_DEFAULT, attrs);
488 assert(res.error == 0);
489 assert(res.msgs.length == 0);
491 /* Search by objectClass */
492 attrs = new Array("dnsHostName", "lastLogon", "objectClass");
493 res = ldb.search("(objectClass=user)", NULL, ldb. SCOPE_DEFAULT, attrs);
494 assert(res.error == 0);
495 assert(res.msgs.length == 2);
496 assert(res.msgs[0].dn == s4.dn("cn=X"));
497 assert(res.msgs[0].dnsHostName == "x");
498 assert(res.msgs[0].lastLogon == "x");
499 assert(res.msgs[0].objectClass != undefined);
500 assert(res.msgs[0].objectClass[0] == "user");
501 assert(res.msgs[1].dn == s4.dn("cn=A"));
502 assert(res.msgs[1].dnsHostName == undefined);
503 assert(res.msgs[1].lastLogon == "x");
504 assert(res.msgs[1].objectClass != undefined);
505 assert(res.msgs[1].objectClass[0] == "user");
507 /* Prove that the objectClass is actually used for the search */
508 res = ldb.search("(|(objectClass=user)(badPwdCount=x))", NULL, ldb. SCOPE_DEFAULT, attrs);
509 assert(res.error == 0);
510 assert(res.msgs.length == 3);
511 assert(res.msgs[0].dn == s4.dn("cn=B"));
512 assert(res.msgs[0].dnsHostName == undefined);
513 assert(res.msgs[0].lastLogon == "y");
514 assert(res.msgs[0].objectClass != undefined);
515 for (i=0;i<res.msgs[0].objectClass.length;i++) {
516 assert(res.msgs[0].objectClass[i] != "user");
518 assert(res.msgs[1].dn == s4.dn("cn=X"));
519 assert(res.msgs[1].dnsHostName == "x");
520 assert(res.msgs[1].lastLogon == "x");
521 assert(res.msgs[1].objectClass != undefined);
522 assert(res.msgs[1].objectClass[0] == "user");
523 assert(res.msgs[2].dn == s4.dn("cn=A"));
524 assert(res.msgs[2].dnsHostName == undefined);
525 assert(res.msgs[2].lastLogon == "x");
526 assert(res.msgs[2].objectClass != undefined);
527 assert(res.msgs[2].objectClass[0] == "user");
529 println("Testing search by parse tree");
531 /* Search by conjunction of local attributes */
532 attrs = new Array("dnsHostName", "lastLogon");
533 res = ldb.search("(&(codePage=x)(revision=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
534 assert(res.error == 0);
535 assert(res.msgs.length == 2);
536 assert(res.msgs[0].dn == s4.dn("cn=Y"));
537 assert(res.msgs[0].dnsHostName == "y");
538 assert(res.msgs[0].lastLogon == "y");
539 assert(res.msgs[1].dn == s4.dn("cn=X"));
540 assert(res.msgs[1].dnsHostName == "x");
541 assert(res.msgs[1].lastLogon == "x");
543 /* Search by conjunction of remote attributes */
544 attrs = new Array("dnsHostName", "lastLogon");
545 res = ldb.search("(&(lastLogon=x)(description=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
546 assert(res.error == 0);
547 assert(res.msgs.length == 2);
548 assert(res.msgs[0].dn == s4.dn("cn=X"));
549 assert(res.msgs[0].dnsHostName == "x");
550 assert(res.msgs[0].lastLogon == "x");
551 assert(res.msgs[1].dn == s4.dn("cn=A"));
552 assert(res.msgs[1].dnsHostName == undefined);
553 assert(res.msgs[1].lastLogon == "x");
555 /* Search by conjunction of local and remote attribute */
556 attrs = new Array("dnsHostName", "lastLogon");
557 res = ldb.search("(&(codePage=x)(description=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
558 assert(res.error == 0);
559 assert(res.msgs.length == 2);
560 assert(res.msgs[0].dn == s4.dn("cn=Y"));
561 assert(res.msgs[0].dnsHostName == "y");
562 assert(res.msgs[0].lastLogon == "y");
563 assert(res.msgs[1].dn == s4.dn("cn=X"));
564 assert(res.msgs[1].dnsHostName == "x");
565 assert(res.msgs[1].lastLogon == "x");
567 /* Search by conjunction of local and remote attribute w/o match */
568 attrs = new Array("dnsHostName", "lastLogon");
569 res = ldb.search("(&(codePage=x)(nextRid=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
570 assert(res.error == 0);
571 assert(res.msgs.length == 0);
572 res = ldb.search("(&(revision=x)(lastLogon=z))", NULL, ldb.SCOPE_DEFAULT, attrs);
573 assert(res.error == 0);
574 assert(res.msgs.length == 0);
576 /* Search by disjunction of local attributes */
577 attrs = new Array("dnsHostName", "lastLogon");
578 res = ldb.search("(|(revision=x)(dnsHostName=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
579 assert(res.error == 0);
580 assert(res.msgs.length == 2);
581 assert(res.msgs[0].dn == s4.dn("cn=Y"));
582 assert(res.msgs[0].dnsHostName == "y");
583 assert(res.msgs[0].lastLogon == "y");
584 assert(res.msgs[1].dn == s4.dn("cn=X"));
585 assert(res.msgs[1].dnsHostName == "x");
586 assert(res.msgs[1].lastLogon == "x");
588 /* Search by disjunction of remote attributes */
589 attrs = new Array("dnsHostName", "lastLogon");
590 res = ldb.search("(|(badPwdCount=x)(lastLogon=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
591 assert(res.error == 0);
592 assert(res.msgs.length == 3);
593 assert(res.msgs[0].dn == s4.dn("cn=B"));
594 assert(res.msgs[0].dnsHostName == undefined);
595 assert(res.msgs[0].lastLogon == "y");
596 assert(res.msgs[1].dn == s4.dn("cn=X"));
597 assert(res.msgs[1].dnsHostName == "x");
598 assert(res.msgs[1].lastLogon == "x");
599 assert(res.msgs[2].dn == s4.dn("cn=A"));
600 assert(res.msgs[2].dnsHostName == undefined);
601 assert(res.msgs[2].lastLogon == "x");
603 /* Search by disjunction of local and remote attribute */
604 attrs = new Array("dnsHostName", "lastLogon");
605 res = ldb.search("(|(revision=x)(lastLogon=y))", NULL, ldb.SCOPE_DEFAULT, attrs);
606 assert(res.error == 0);
607 assert(res.msgs.length == 3);
608 assert(res.msgs[0].dn == s4.dn("cn=Y"));
609 assert(res.msgs[0].dnsHostName == "y");
610 assert(res.msgs[0].lastLogon == "y");
611 assert(res.msgs[1].dn == s4.dn("cn=B"));
612 assert(res.msgs[1].dnsHostName == undefined);
613 assert(res.msgs[1].lastLogon == "y");
614 assert(res.msgs[2].dn == s4.dn("cn=X"));
615 assert(res.msgs[2].dnsHostName == "x");
616 assert(res.msgs[2].lastLogon == "x");
618 /* Search by disjunction of local and remote attribute w/o match */
619 attrs = new Array("dnsHostName", "lastLogon");
620 res = ldb.search("(|(codePage=y)(nextRid=z))", NULL, ldb.SCOPE_DEFAULT, attrs);
621 assert(res.error == 0);
622 assert(res.msgs.length == 0);
624 /* Search by negated local attribute */
625 attrs = new Array("dnsHostName", "lastLogon");
626 res = ldb.search("(!(revision=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
627 assert(res.error == 0);
628 assert(res.msgs.length == 5);
629 assert(res.msgs[0].dn == s4.dn("cn=B"));
630 assert(res.msgs[0].dnsHostName == undefined);
631 assert(res.msgs[0].lastLogon == "y");
632 assert(res.msgs[1].dn == s4.dn("cn=A"));
633 assert(res.msgs[1].dnsHostName == undefined);
634 assert(res.msgs[1].lastLogon == "x");
635 assert(res.msgs[2].dn == s4.dn("cn=Z"));
636 assert(res.msgs[2].dnsHostName == "z");
637 assert(res.msgs[2].lastLogon == "z");
638 assert(res.msgs[3].dn == s4.dn("cn=C"));
639 assert(res.msgs[3].dnsHostName == undefined);
640 assert(res.msgs[3].lastLogon == "z");
642 /* Search by negated remote attribute */
643 attrs = new Array("dnsHostName", "lastLogon");
644 res = ldb.search("(!(description=x))", NULL, ldb.SCOPE_DEFAULT, attrs);
645 assert(res.error == 0);
646 assert(res.msgs.length == 3);
647 assert(res.msgs[0].dn == s4.dn("cn=Z"));
648 assert(res.msgs[0].dnsHostName == "z");
649 assert(res.msgs[0].lastLogon == "z");
650 assert(res.msgs[1].dn == s4.dn("cn=C"));
651 assert(res.msgs[1].dnsHostName == undefined);
652 assert(res.msgs[1].lastLogon == "z");
654 /* Search by negated conjunction of local attributes */
655 attrs = new Array("dnsHostName", "lastLogon");
656 res = ldb.search("(!(&(codePage=x)(revision=x)))", NULL, ldb.SCOPE_DEFAULT, attrs);
657 assert(res.error == 0);
658 assert(res.msgs.length == 5);
659 assert(res.msgs[0].dn == s4.dn("cn=B"));
660 assert(res.msgs[0].dnsHostName == undefined);
661 assert(res.msgs[0].lastLogon == "y");
662 assert(res.msgs[1].dn == s4.dn("cn=A"));
663 assert(res.msgs[1].dnsHostName == undefined);
664 assert(res.msgs[1].lastLogon == "x");
665 assert(res.msgs[2].dn == s4.dn("cn=Z"));
666 assert(res.msgs[2].dnsHostName == "z");
667 assert(res.msgs[2].lastLogon == "z");
668 assert(res.msgs[3].dn == s4.dn("cn=C"));
669 assert(res.msgs[3].dnsHostName == undefined);
670 assert(res.msgs[3].lastLogon == "z");
672 /* Search by negated conjunction of remote attributes */
673 attrs = new Array("dnsHostName", "lastLogon");
674 res = ldb.search("(!(&(lastLogon=x)(description=x)))", NULL, ldb.SCOPE_DEFAULT, attrs);
675 assert(res.error == 0);
676 assert(res.msgs.length == 5);
677 assert(res.msgs[0].dn == s4.dn("cn=Y"));
678 assert(res.msgs[0].dnsHostName == "y");
679 assert(res.msgs[0].lastLogon == "y");
680 assert(res.msgs[1].dn == s4.dn("cn=B"));
681 assert(res.msgs[1].dnsHostName == undefined);
682 assert(res.msgs[1].lastLogon == "y");
683 assert(res.msgs[2].dn == s4.dn("cn=Z"));
684 assert(res.msgs[2].dnsHostName == "z");
685 assert(res.msgs[2].lastLogon == "z");
686 assert(res.msgs[3].dn == s4.dn("cn=C"));
687 assert(res.msgs[3].dnsHostName == undefined);
688 assert(res.msgs[3].lastLogon == "z");
690 /* Search by negated conjunction of local and remote attribute */
691 attrs = new Array("dnsHostName", "lastLogon");
692 res = ldb.search("(!(&(codePage=x)(description=x)))", NULL, ldb.SCOPE_DEFAULT, attrs);
693 assert(res.error == 0);
694 assert(res.msgs.length == 5);
695 assert(res.msgs[0].dn == s4.dn("cn=B"));
696 assert(res.msgs[0].dnsHostName == undefined);
697 assert(res.msgs[0].lastLogon == "y");
698 assert(res.msgs[1].dn == s4.dn("cn=A"));
699 assert(res.msgs[1].dnsHostName == undefined);
700 assert(res.msgs[1].lastLogon == "x");
701 assert(res.msgs[2].dn == s4.dn("cn=Z"));
702 assert(res.msgs[2].dnsHostName == "z");
703 assert(res.msgs[2].lastLogon == "z");
704 assert(res.msgs[3].dn == s4.dn("cn=C"));
705 assert(res.msgs[3].dnsHostName == undefined);
706 assert(res.msgs[3].lastLogon == "z");
708 /* Search by negated disjunction of local attributes */
709 attrs = new Array("dnsHostName", "lastLogon");
710 res = ldb.search("(!(|(revision=x)(dnsHostName=x)))", NULL, ldb.SCOPE_DEFAULT, attrs);
711 assert(res.error == 0);
712 assert(res.msgs[0].dn == s4.dn("cn=B"));
713 assert(res.msgs[0].dnsHostName == undefined);
714 assert(res.msgs[0].lastLogon == "y");
715 assert(res.msgs[1].dn == s4.dn("cn=A"));
716 assert(res.msgs[1].dnsHostName == undefined);
717 assert(res.msgs[1].lastLogon == "x");
718 assert(res.msgs[2].dn == s4.dn("cn=Z"));
719 assert(res.msgs[2].dnsHostName == "z");
720 assert(res.msgs[2].lastLogon == "z");
721 assert(res.msgs[3].dn == s4.dn("cn=C"));
722 assert(res.msgs[3].dnsHostName == undefined);
723 assert(res.msgs[3].lastLogon == "z");
725 /* Search by negated disjunction of remote attributes */
726 attrs = new Array("dnsHostName", "lastLogon");
727 res = ldb.search("(!(|(badPwdCount=x)(lastLogon=x)))", NULL, ldb.SCOPE_DEFAULT, attrs);
728 assert(res.error == 0);
729 assert(res.msgs.length == 4);
730 assert(res.msgs[0].dn == s4.dn("cn=Y"));
731 assert(res.msgs[0].dnsHostName == "y");
732 assert(res.msgs[0].lastLogon == "y");
733 assert(res.msgs[1].dn == s4.dn("cn=Z"));
734 assert(res.msgs[1].dnsHostName == "z");
735 assert(res.msgs[1].lastLogon == "z");
736 assert(res.msgs[2].dn == s4.dn("cn=C"));
737 assert(res.msgs[2].dnsHostName == undefined);
738 assert(res.msgs[2].lastLogon == "z");
740 /* Search by negated disjunction of local and remote attribute */
741 attrs = new Array("dnsHostName", "lastLogon");
742 res = ldb.search("(!(|(revision=x)(lastLogon=y)))", NULL, ldb.SCOPE_DEFAULT, attrs);
743 assert(res.error == 0);
744 assert(res.msgs.length == 4);
745 assert(res.msgs[0].dn == s4.dn("cn=A"));
746 assert(res.msgs[0].dnsHostName == undefined);
747 assert(res.msgs[0].lastLogon == "x");
748 assert(res.msgs[1].dn == s4.dn("cn=Z"));
749 assert(res.msgs[1].dnsHostName == "z");
750 assert(res.msgs[1].lastLogon == "z");
751 assert(res.msgs[2].dn == s4.dn("cn=C"));
752 assert(res.msgs[2].dnsHostName == undefined);
753 assert(res.msgs[2].lastLogon == "z");
755 println("Search by complex parse tree");
756 attrs = new Array("dnsHostName", "lastLogon");
757 res = ldb.search("(|(&(revision=x)(dnsHostName=x))(!(&(description=x)(nextRid=y)))(badPwdCount=y))", NULL, ldb.SCOPE_DEFAULT, attrs);
758 assert(res.error == 0);
759 assert(res.msgs.length == 6);
760 assert(res.msgs[0].dn == s4.dn("cn=B"));
761 assert(res.msgs[0].dnsHostName == undefined);
762 assert(res.msgs[0].lastLogon == "y");
763 assert(res.msgs[1].dn == s4.dn("cn=X"));
764 assert(res.msgs[1].dnsHostName == "x");
765 assert(res.msgs[1].lastLogon == "x");
766 assert(res.msgs[2].dn == s4.dn("cn=A"));
767 assert(res.msgs[2].dnsHostName == undefined);
768 assert(res.msgs[2].lastLogon == "x");
769 assert(res.msgs[3].dn == s4.dn("cn=Z"));
770 assert(res.msgs[3].dnsHostName == "z");
771 assert(res.msgs[3].lastLogon == "z");
772 assert(res.msgs[4].dn == s4.dn("cn=C"));
773 assert(res.msgs[4].dnsHostName == undefined);
774 assert(res.msgs[4].lastLogon == "z");
777 var dns = new Array();
778 dns[0] = s4.dn("cn=A");
779 dns[1] = s4.dn("cn=B");
780 dns[2] = s4.dn("cn=C");
781 dns[3] = s4.dn("cn=X");
782 dns[4] = s4.dn("cn=Y");
783 dns[5] = s4.dn("cn=Z");
784 for (i=0;i<dns.length;i++) {
785 var ok = ldb.del(dns[i]);
786 assert(ok.error == 0);
790 function test_map_modify(ldb, s3, s4)
792 println("Running modification tests on mapped data");
800 println("Testing modification of local records");
802 /* Add local record */
803 dn = "cn=test,dc=idealx,dc=org";
812 assert(ok.error == 0);
813 /* Check it's there */
814 attrs = new Array("foo", "revision", "description");
815 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
816 assert(res.error == 0);
817 assert(res.msgs.length == 1);
818 assert(res.msgs[0].dn == dn);
819 assert(res.msgs[0].foo == "bar");
820 assert(res.msgs[0].revision == "1");
821 assert(res.msgs[0].description == "test");
822 /* Check it's not in the local db */
823 res = s4.db.search("(cn=test)", NULL, ldb.SCOPE_DEFAULT, attrs);
824 assert(res.error == 0);
825 assert(res.msgs.length == 0);
826 /* Check it's not in the remote db */
827 res = s3.db.search("(cn=test)", NULL, ldb.SCOPE_DEFAULT, attrs);
828 assert(res.error == 0);
829 assert(res.msgs.length == 0);
831 /* Modify local record */
839 ok = ldb.modify(ldif);
840 assert(ok.error == 0);
841 /* Check in local db */
842 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
843 assert(res.error == 0);
844 assert(res.msgs.length == 1);
845 assert(res.msgs[0].dn == dn);
846 assert(res.msgs[0].foo == "baz");
847 assert(res.msgs[0].revision == "1");
848 assert(res.msgs[0].description == "foo");
850 /* Rename local record */
851 dn2 = "cn=toast,dc=idealx,dc=org";
852 ok = ldb.rename(dn, dn2);
853 assert(ok.error == 0);
854 /* Check in local db */
855 res = ldb.search("", dn2, ldb.SCOPE_BASE, attrs);
856 assert(res.error == 0);
857 assert(res.msgs.length == 1);
858 assert(res.msgs[0].dn == dn2);
859 assert(res.msgs[0].foo == "baz");
860 assert(res.msgs[0].revision == "1");
861 assert(res.msgs[0].description == "foo");
863 /* Delete local record */
865 assert(ok.error == 0);
866 /* Check it's gone */
867 res = ldb.search("", dn2, ldb.SCOPE_BASE);
868 assert(res.error == 0);
869 assert(res.msgs.length == 0);
871 println("Testing modification of remote records");
873 /* Add remote record */
874 dn = s4.dn("cn=test");
875 dn2 = s3.dn("cn=test");
880 sambaBadPasswordCount: 3
883 ok = s3.db.add(ldif);
884 assert(ok.error == 0);
885 /* Check it's there */
886 attrs = new Array("description", "sambaBadPasswordCount", "sambaNextRid");
887 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
888 assert(res.error == 0);
889 assert(res.msgs.length == 1);
890 assert(res.msgs[0].dn == dn2);
891 assert(res.msgs[0].description == "foo");
892 assert(res.msgs[0].sambaBadPasswordCount == "3");
893 assert(res.msgs[0].sambaNextRid == "1001");
894 /* Check in mapped db */
895 attrs = new Array("description", "badPwdCount", "nextRid");
896 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
897 assert(res.error == 0);
898 assert(res.msgs.length == 1);
899 assert(res.msgs[0].dn == dn);
900 assert(res.msgs[0].description == "foo");
901 assert(res.msgs[0].badPwdCount == "3");
902 assert(res.msgs[0].nextRid == "1001");
903 /* Check in local db */
904 res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs);
905 assert(res.error == 0);
906 assert(res.msgs.length == 0);
908 /* Modify remote data of remote record */
916 ok = ldb.modify(ldif);
919 assert(ok.error == 0);
921 /* Check in mapped db */
922 attrs = new Array("description", "badPwdCount", "nextRid");
923 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
924 assert(res.error == 0);
925 assert(res.msgs.length == 1);
926 assert(res.msgs[0].dn == dn);
927 assert(res.msgs[0].description == "test");
928 assert(res.msgs[0].badPwdCount == "4");
929 assert(res.msgs[0].nextRid == "1001");
930 /* Check in remote db */
931 attrs = new Array("description", "sambaBadPasswordCount", "sambaNextRid");
932 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
933 assert(res.error == 0);
934 assert(res.msgs.length == 1);
935 assert(res.msgs[0].dn == dn2);
936 assert(res.msgs[0].description == "test");
937 assert(res.msgs[0].sambaBadPasswordCount == "4");
938 assert(res.msgs[0].sambaNextRid == "1001");
940 /* Rename remote record */
941 dn2 = s4.dn("cn=toast");
942 ok = ldb.rename(dn, dn2);
943 assert(ok.error == 0);
944 /* Check in mapped db */
946 attrs = new Array("description", "badPwdCount", "nextRid");
947 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
948 assert(res.error == 0);
949 assert(res.msgs.length == 1);
950 assert(res.msgs[0].dn == dn);
951 assert(res.msgs[0].description == "test");
952 assert(res.msgs[0].badPwdCount == "4");
953 assert(res.msgs[0].nextRid == "1001");
954 /* Check in remote db */
955 dn2 = s3.dn("cn=toast");
956 attrs = new Array("description", "sambaBadPasswordCount", "sambaNextRid");
957 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
958 assert(res.error == 0);
959 assert(res.msgs.length == 1);
960 assert(res.msgs[0].dn == dn2);
961 assert(res.msgs[0].description == "test");
962 assert(res.msgs[0].sambaBadPasswordCount == "4");
963 assert(res.msgs[0].sambaNextRid == "1001");
965 /* Delete remote record */
967 assert(ok.error == 0);
968 /* Check in mapped db */
969 res = ldb.search("", dn, ldb.SCOPE_BASE);
970 assert(res.error == 0);
971 assert(res.msgs.length == 0);
972 /* Check in remote db */
973 res = s3.db.search("", dn2, ldb.SCOPE_BASE);
974 assert(res.error == 0);
975 assert(res.msgs.length == 0);
977 /* Add remote record (same as before) */
978 dn = s4.dn("cn=test");
979 dn2 = s3.dn("cn=test");
984 sambaBadPasswordCount: 3
987 ok = s3.db.add(ldif);
988 assert(ok.error == 0);
990 /* Modify local data of remote record */
998 ok = ldb.modify(ldif);
1001 assert(ok.error == 0);
1003 /* Check in mapped db */
1004 attrs = new Array("revision", "description");
1005 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
1006 assert(res.error == 0);
1007 assert(res.msgs.length == 1);
1008 assert(res.msgs[0].dn == dn);
1009 assert(res.msgs[0].description == "test");
1010 assert(res.msgs[0].revision == "1");
1011 /* Check in remote db */
1012 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
1013 assert(res.error == 0);
1014 assert(res.msgs.length == 1);
1015 assert(res.msgs[0].dn == dn2);
1016 assert(res.msgs[0].description == "test");
1017 assert(res.msgs[0].revision == undefined);
1018 /* Check in local db */
1019 res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs);
1020 assert(res.error == 0);
1021 assert(res.msgs.length == 1);
1022 assert(res.msgs[0].dn == dn);
1023 assert(res.msgs[0].description == undefined);
1024 assert(res.msgs[0].revision == "1");
1026 /* Delete (newly) split record */
1028 assert(ok.error == 0);
1030 println("Testing modification of split records");
1032 /* Add split record */
1033 dn = s4.dn("cn=test");
1034 dn2 = s3.dn("cn=test");
1044 assert(ok.error == 0);
1045 /* Check it's there */
1046 attrs = new Array("description", "badPwdCount", "nextRid", "revision");
1047 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
1048 assert(res.error == 0);
1049 assert(res.msgs.length == 1);
1050 assert(res.msgs[0].dn == dn);
1051 assert(res.msgs[0].description == "foo");
1052 assert(res.msgs[0].badPwdCount == "3");
1053 assert(res.msgs[0].nextRid == "1001");
1054 assert(res.msgs[0].revision == "1");
1055 /* Check in local db */
1056 res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs);
1057 assert(res.error == 0);
1058 assert(res.msgs.length == 1);
1059 assert(res.msgs[0].dn == dn);
1060 assert(res.msgs[0].description == undefined);
1061 assert(res.msgs[0].badPwdCount == undefined);
1062 assert(res.msgs[0].nextRid == undefined);
1063 assert(res.msgs[0].revision == "1");
1064 /* Check in remote db */
1065 attrs = new Array("description", "sambaBadPasswordCount", "sambaNextRid", "revision");
1066 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
1067 assert(res.error == 0);
1068 assert(res.msgs.length == 1);
1069 assert(res.msgs[0].dn == dn2);
1070 assert(res.msgs[0].description == "foo");
1071 assert(res.msgs[0].sambaBadPasswordCount == "3");
1072 assert(res.msgs[0].sambaNextRid == "1001");
1073 assert(res.msgs[0].revision == undefined);
1075 /* Modify of split record */
1078 replace: description
1080 replace: badPwdCount
1085 ok = ldb.modify(ldif);
1086 assert(ok.error == 0);
1087 /* Check in mapped db */
1088 attrs = new Array("description", "badPwdCount", "nextRid", "revision");
1089 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
1090 assert(res.error == 0);
1091 assert(res.msgs.length == 1);
1092 assert(res.msgs[0].dn == dn);
1093 assert(res.msgs[0].description == "test");
1094 assert(res.msgs[0].badPwdCount == "4");
1095 assert(res.msgs[0].nextRid == "1001");
1096 assert(res.msgs[0].revision == "2");
1097 /* Check in local db */
1098 res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs);
1099 assert(res.error == 0);
1100 assert(res.msgs.length == 1);
1101 assert(res.msgs[0].dn == dn);
1102 assert(res.msgs[0].description == undefined);
1103 assert(res.msgs[0].badPwdCount == undefined);
1104 assert(res.msgs[0].nextRid == undefined);
1105 assert(res.msgs[0].revision == "2");
1106 /* Check in remote db */
1107 attrs = new Array("description", "sambaBadPasswordCount", "sambaNextRid", "revision");
1108 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
1109 assert(res.error == 0);
1110 assert(res.msgs.length == 1);
1111 assert(res.msgs[0].dn == dn2);
1112 assert(res.msgs[0].description == "test");
1113 assert(res.msgs[0].sambaBadPasswordCount == "4");
1114 assert(res.msgs[0].sambaNextRid == "1001");
1115 assert(res.msgs[0].revision == undefined);
1117 /* Rename split record */
1118 dn2 = s4.dn("cn=toast");
1119 ok = ldb.rename(dn, dn2);
1120 assert(ok.error == 0);
1121 /* Check in mapped db */
1123 attrs = new Array("description", "badPwdCount", "nextRid", "revision");
1124 res = ldb.search("", dn, ldb.SCOPE_BASE, attrs);
1125 assert(res.error == 0);
1126 assert(res.msgs.length == 1);
1127 assert(res.msgs[0].dn == dn);
1128 assert(res.msgs[0].description == "test");
1129 assert(res.msgs[0].badPwdCount == "4");
1130 assert(res.msgs[0].nextRid == "1001");
1131 assert(res.msgs[0].revision == "2");
1132 /* Check in local db */
1133 res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs);
1134 assert(res.error == 0);
1135 assert(res.msgs.length == 1);
1136 assert(res.msgs[0].dn == dn);
1137 assert(res.msgs[0].description == undefined);
1138 assert(res.msgs[0].badPwdCount == undefined);
1139 assert(res.msgs[0].nextRid == undefined);
1140 assert(res.msgs[0].revision == "2");
1141 /* Check in remote db */
1142 dn2 = s3.dn("cn=toast");
1143 attrs = new Array("description", "sambaBadPasswordCount", "sambaNextRid", "revision");
1144 res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs);
1145 assert(res.error == 0);
1146 assert(res.msgs.length == 1);
1147 assert(res.msgs[0].dn == dn2);
1148 assert(res.msgs[0].description == "test");
1149 assert(res.msgs[0].sambaBadPasswordCount == "4");
1150 assert(res.msgs[0].sambaNextRid == "1001");
1151 assert(res.msgs[0].revision == undefined);
1153 /* Delete split record */
1155 assert(ok.error == 0);
1156 /* Check in mapped db */
1157 res = ldb.search("", dn, ldb.SCOPE_BASE);
1158 assert(res.error == 0);
1159 assert(res.msgs.length == 0);
1160 /* Check in local db */
1161 res = s4.db.search("", dn, ldb.SCOPE_BASE);
1162 assert(res.error == 0);
1163 assert(res.msgs.length == 0);
1164 /* Check in remote db */
1165 res = s3.db.search("", dn2, ldb.SCOPE_BASE);
1166 assert(res.error == 0);
1167 assert(res.msgs.length == 0);
1170 function make_dn(rdn)
1172 return rdn + ",sambaDomainName=TESTS," + this.BASEDN;
1175 function make_s4dn(rdn)
1177 return rdn + "," + this.BASEDN;
1180 var ldb = ldb_init();
1183 var ldbfile = prefix + "/" + "test.ldb";
1184 var ldburl = "tdb://" + ldbfile;
1186 var samba4 = new Object("samba4 partition info");
1187 samba4.file = prefix + "/" + "samba4.ldb";
1188 samba4.url = "tdb://" + samba4.file;
1189 samba4.BASEDN = "dc=vernstok,dc=nl";
1190 samba4.db = ldb_init();
1191 samba4.dn = make_s4dn;
1193 var samba3 = new Object("samba3 partition info");
1194 samba3.file = prefix + "/" + "samba3.ldb";
1195 samba3.url = "tdb://" + samba3.file;
1196 samba3.BASEDN = "cn=Samba3Sam";
1197 samba3.db = ldb_init();
1198 samba3.dn = make_dn;
1200 var templates = new Object("templates partition info");
1201 templates.file = prefix + "/" + "templates.ldb";
1202 templates.url = "tdb://" + templates.file;
1203 templates.BASEDN = "cn=templates";
1204 templates.db = ldb_init();
1206 sys.unlink(ldbfile);
1207 sys.unlink(samba3.file);
1208 sys.unlink(templates.file);
1209 sys.unlink(samba4.file);
1211 var ok = ldb.connect(ldburl);
1213 var ok = samba3.db.connect(samba3.url);
1215 var ok = templates.db.connect(templates.url);
1217 var ok = samba4.db.connect(samba4.url);
1220 setup_data(samba3, sys.file_load(datadir + "/" + "samba3.ldif"));
1221 setup_data(templates, sys.file_load(datadir + "/" + "provision_samba3sam_templates.ldif"));
1222 setup_modules(ldb, samba3, samba4, sys.file_load(datadir + "/" + "provision_samba3sam.ldif"));
1225 var ok = ldb.connect(ldburl);
1228 test_s3sam_search(ldb);
1229 test_s3sam_modify(ldb, samba3);
1231 sys.unlink(ldbfile);
1232 sys.unlink(samba3.file);
1233 sys.unlink(templates.file);
1234 sys.unlink(samba4.file);
1237 var ok = ldb.connect(ldburl);
1239 samba3.db = ldb_init();
1240 var ok = samba3.db.connect(samba3.url);
1242 templates.db = ldb_init();
1243 var ok = templates.db.connect(templates.url);
1245 samba4.db = ldb_init();
1246 var ok = samba4.db.connect(samba4.url);
1249 setup_data(templates, sys.file_load(datadir + "/" + "provision_samba3sam_templates.ldif"));
1250 setup_modules(ldb, samba3, samba4, sys.file_load(datadir + "provision_samba3sam.ldif"));
1253 var ok = ldb.connect(ldburl);
1256 test_map_search(ldb, samba3, samba4);
1257 test_map_modify(ldb, samba3, samba4);
1259 sys.unlink(ldbfile);
1260 sys.unlink(samba3.file);
1261 sys.unlink(samba4.file);