Convert some more files to GPLv3.
[jra/samba/.git] / source4 / scripting / libjs / provision.js
index 5c4ff6877f23e1a17b439b5f4848d2654d92eb6c..51e2785762bd79a29c2beba5b478f08066f80a05 100644 (file)
@@ -1,7 +1,7 @@
 /*
        backend code for provisioning a Samba4 server
        Copyright Andrew Tridgell 2005
-       Released under the GNU GPL v2 or later
+       Released under the GNU GPL version 3 or later
 */
 
 sys = sys_init();
@@ -389,6 +389,7 @@ function provision_default_paths(subobj)
        paths.smbconf = lp.filename()
        paths.shareconf = lp.get("private dir") + "/" + "share.ldb";
        paths.samdb = lp.get("sam database");
+       paths.idmapdb = lp.get("idmap database");
        paths.secrets = lp.get("secrets database");
        paths.templates = lp.get("private dir") + "/" + "templates.ldb";
        paths.keytab = "secrets.keytab";
@@ -524,6 +525,10 @@ function provision_become_dc(subobj, message, erase, paths, session_info)
        var ok = provision_fix_subobj(subobj, paths);
        assert(ok);
 
+       if (subobj.BACKEND_MOD == undefined) {
+               subobj.BACKEND_MOD = "repl_meta_data";
+       }
+
        info.subobj = subobj;
        info.message = message;
        info.session_info = session_info;
@@ -610,10 +615,21 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
        var lp = loadparm_init();
        var sys = sys_init();
        var info = new Object();
+       random_init(local);
 
        var ok = provision_fix_subobj(subobj, paths);
        assert(ok);
 
+       if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
+               if (subobj.BACKEND_MOD == undefined) {
+                       subobj.BACKEND_MOD = "repl_meta_data";
+               }
+       } else {
+               if (subobj.BACKEND_MOD == undefined) {
+                       subobj.BACKEND_MOD = "objectguid";
+               }
+       }
+
        if (subobj.DOMAINGUID != undefined) {
                subobj.DOMAINGUID_MOD = sprintf("replace: objectGUID\nobjectGUID: %s\n-", subobj.DOMAINGUID);
        } else {
@@ -664,6 +680,9 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
        message("Setting up templates into " + paths.templates + "\n");
        setup_ldb("provision_templates.ldif", info, paths.templates);
 
+       message("Setting up " + paths.idmapdb +"\n");
+       setup_ldb("idmap_init.ldif", info, paths.idmapdb);
+
        message("Setting up sam.ldb partitions\n");
        /* Also wipes the database */
        setup_ldb("provision_partitions.ldif", info, paths.samdb);
@@ -693,6 +712,20 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
 
        samdb.set_domain_sid(subobj.DOMAINSID);
 
+       if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
+               if (subobj.INVOCATIONID == undefined) {
+                       subobj.INVOCATIONID = randguid();
+               }
+               samdb.set_ntds_invocationId(subobj.INVOCATIONID);
+               if (subobj.BACKEND_MOD == undefined) {
+                       subobj.BACKEND_MOD = "repl_meta_data";
+               }
+       } else {
+               if (subobj.BACKEND_MOD == undefined) {
+                       subobj.BACKEND_MOD = "objectguid";
+               }
+       }
+
        var load_schema_ok = load_schema(subobj, message, samdb);
        assert(load_schema_ok.is_ok);
 
@@ -958,7 +991,6 @@ function provision_guess()
        subobj.VERSION      = version();
        subobj.HOSTIP       = hostip();
        subobj.DOMAINSID    = randsid();
-       subobj.INVOCATIONID = randguid();
        subobj.POLICYGUID   = randguid();
        subobj.KRBTGTPASS   = randpass(12);
        subobj.MACHINEPASS  = randpass(12);
@@ -1010,9 +1042,6 @@ function provision_guess()
        subobj.DOMAINDN_MOD = "pdc_fsmo,password_hash,instancetype";
        subobj.CONFIGDN_MOD = "naming_fsmo,instancetype";
        subobj.SCHEMADN_MOD = "schema_fsmo,instancetype";
-       subobj.DOMAINDN_MOD2 = ",objectguid";
-       subobj.CONFIGDN_MOD2 = ",objectguid";
-       subobj.SCHEMADN_MOD2 = ",objectguid";
 
        subobj.ACI              = "# no aci for local ldb";
 
@@ -1099,7 +1128,7 @@ unixName: %s
 sambaPassword: %s
 objectClass: user
 ",
-                          user_dn, username, dom_users,
+                          user_dn, username,
                           unixname, password);
        /*
          add the user to the users group as well
@@ -1109,7 +1138,7 @@ dn: %s
 changetype: modify
 add: member
 member: %s
-", 
+",
                               dom_users, user_dn);
 
 
@@ -1145,7 +1174,7 @@ member: %s
 // crh has a paragraph on this in his book (1.4.1.1)
 function valid_netbios_name(name)
 {
-       if (strlen(name) > 13) return false;
+       if (strlen(name) > 15) return false;
        return true;
 }