mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
152c1a37b5
Add SOC STATUS doc
194 lines
4.8 KiB
Plaintext
Executable File
194 lines
4.8 KiB
Plaintext
Executable File
#!/usr/bin/env smbscript
|
|
/* (C) Jelmer Vernooij <jelmer@samba.org> 2005
|
|
Published under the GNU GPL
|
|
Sponsored by Google Summer of Code
|
|
*/
|
|
|
|
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);
|
|
|
|
var ldif = sys.file_load(mypath + "../../source/setup/provision_templates.ldif");
|
|
var subobj = new Object();
|
|
subobj.BASEDN = "dc=vernstok,dc=nl";
|
|
ldif = substitute_var(ldif, subobj);
|
|
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);
|
|
|
|
println("Looking up by non-mapped attribute");
|
|
msg = s4.search("(cn=Administrator)");
|
|
assert(msg[0].cn == "Administrator");
|
|
assert(msg.length == 1);
|
|
|
|
println("Looking up by mapped attribute");
|
|
msg = s4.search("(name=Backup Operators)");
|
|
assert(msg[0].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 == 0);
|
|
|
|
println("Looking up mapped entry containing SID");
|
|
msg = s4.search("(cn=Replicator)");
|
|
assert(msg.length == 1);
|
|
assert(msg[0].dn == "cn=Replicator,ou=Groups,sambaDomainName=TESTS,dc=vernstok,dc=nl");
|
|
assert(msg[0].objectSid == "S-1-5-21-4231626423-2410014848-2360679739-552");
|
|
|
|
println("Checking mapping of objectclass");
|
|
var oc = msg[0].objectclass;
|
|
for (var i in oc) {
|
|
assert(oc[i] == "posixGroup" || oc[i] == "group");
|
|
}
|
|
|
|
println("Adding a record that will be fallbacked");
|
|
ok = s4.add("
|
|
dn: cn=Foo,dc=idealx,dc=org
|
|
foo: bar
|
|
blah: Blie
|
|
cn: Foo
|
|
showInAdvancedViewOnly: TRUE
|
|
");
|
|
assert(ok);
|
|
|
|
println("Checking for existance of record");
|
|
msg = s4.search("(cn=Foo)", new Array('foo','blah','cn','showInAdvancedViewOnly'));
|
|
assert(msg.length == 1);
|
|
assert(msg[0].showInAdvancedViewOnly == "TRUE");
|
|
assert(msg[0].foo == "bar");
|
|
assert(msg[0].blah == "Blie");
|
|
|
|
println("Adding record that will be mapped");
|
|
ok = s4.add("
|
|
dn: cn=Niemand,sambaDomainName=TESTS,dc=vernstok,dc=nl
|
|
objectClass: user
|
|
unixName: bin
|
|
unicodePwd: geheim
|
|
cn: Niemand
|
|
");
|
|
assert(ok);
|
|
|
|
println("Checking for existance of record (mapped)");
|
|
msg = s4.search("(unixName=bin)", new Array('unixName','cn','dn'));
|
|
assert(msg.length == 1);
|
|
assert(msg[0].cn == "Niemand");
|
|
|
|
println("Checking for data in destination database");
|
|
msg = s3.search("(cn=Niemand)");
|
|
assert(msg.length >= 1);
|
|
assert(msg[0].sambaSID == "S-1-5-21-4231626423-2410014848-2360679739-2001");
|
|
assert(msg[0].displayName == "Niemand");
|
|
|
|
println("Adding attribute...");
|
|
ok = s4.modify("
|
|
dn: cn=Niemand,sambaDomainName=TESTS,dc=vernstok,dc=nl
|
|
changetype: modify
|
|
add: description
|
|
description: Blah
|
|
");
|
|
assert(ok);
|
|
|
|
println("Checking whether changes are still there...");
|
|
msg = s4.search("(cn=Niemand)");
|
|
assert(msg.length >= 1);
|
|
assert(msg[0].cn == "Niemand");
|
|
assert(msg[0].description == "Blah");
|
|
|
|
println("Modifying attribute...");
|
|
ok = s4.modify("
|
|
dn: cn=Niemand,sambaDomainName=TESTS,dc=vernstok,dc=nl
|
|
changetype: modify
|
|
replace: description
|
|
description: Blie
|
|
");
|
|
assert(ok);
|
|
|
|
println("Checking whether changes are still there...");
|
|
msg = s4.search("(cn=Niemand)");
|
|
assert(msg.length >= 1);
|
|
assert(msg[0].description == "Blie");
|
|
|
|
println("Deleting attribute...");
|
|
ok = s4.modify("
|
|
dn: cn=Niemand,sambaDomainName=TESTS,dc=vernstok,dc=nl
|
|
changetype: modify
|
|
delete: description
|
|
");
|
|
assert(ok);
|
|
|
|
println("Checking whether changes are no longer there...");
|
|
msg = s4.search("(cn=Niemand)");
|
|
assert(msg.length >= 1);
|
|
assert(msg[0].description == undefined);
|
|
|
|
println("Renaming record...");
|
|
ok = s4.rename("cn=Niemand,sambaDomainName=TESTS,dc=vernstok,dc=nl", "cn=Niemand,dc=vernstok,dc=nl");
|
|
|
|
println("Checking whether DN has changed...");
|
|
msg = s4.search("(cn=Niemand)");
|
|
assert(msg.length == 1);
|
|
assert(msg[0].dn == "cn=Niemand,dc=vernstok,dc=nl");
|
|
|
|
println("Deleting record...");
|
|
ok = s4.del("cn=Niemand,dc=vernstok,dc=nl");
|
|
assert(ok);
|
|
|
|
println("Checking whether record is gone...");
|
|
msg = s4.search("(cn=Niemand)");
|
|
assert(msg.length == 0);
|
|
|
|
return 0;
|