1 <% page_header("columns", "Windows to Samba Migration", "install");
3 include("/scripting/forms.js");
5 libinclude("provision.js");
7 var misc = misc_init();
10 <h1>Windows to Samba4 domain migration</h1>
13 var f = FormObj("Provisioning", 0, 2);
15 var lp = loadparm_init();
17 if ((session.authinfo.user_class == "ADMINISTRATOR")
18 || (session.authinfo.user_class == "SYSTEM")) {
20 if (lp.get("realm") == "") {
21 lp.set("realm", lp.get("workgroup") + ".example.com");
25 var subobj = provision_guess();
26 /* Don't supply default password for web interface */
27 subobj.ADMINPASS = "";
29 f.add("REALM", "DNS Domain Name");
30 f.add("DOMAIN", "NetBIOS Domain Name");
31 f.add("ADMIN", "Administrator Username");
32 f.add("ADMINPASS", "Administrator Password", "password");
33 f.add("HOSTNAME", "My Hostname");
34 f.add("HOSTIP", "My Host's IP");
35 f.add("DEFAULTSITE", "Default Site");
36 f.submit[0] = "Migrate";
37 f.submit[1] = "Cancel";
39 if (form['submit'] == "Cancel") {
43 if (form['submit'] == "Migrate") {
49 for (i=0;i<f.element.length;i++) {
50 f.element[i].value = subobj[f.element[i].name];
53 if (form['submit'] == "Migrate") {
54 /* overcome an initially blank smb.conf */
55 lp.set("realm", subobj.REALM);
56 lp.set("workgroup", subobj.DOMAIN);
59 if (subobj.ADMINPASS == "") {
60 write("<h3>We need the administrator password for the " + subobj.DOMAIN + " domain to proceed. Please try again.</h3>");
62 } else if (!provision_validate(subobj, writefln)) {
64 } else if (strupper(lp.get("server role")) == "domain controller") {
65 writefln("You need to set 'server role' to 'member server' before starting the migration process");
67 var creds = credentials_init();
69 creds.set_username(form.ADMIN);
70 creds.set_password(form.ADMINPASS);
71 creds.set_domain(form.DOMAIN);
72 creds.set_realm(form.REALM);
74 var info = new Object();
75 var paths = provision_default_paths(subobj);
76 var session_info = session.authinfo.session_info;
77 var credentials = session.authinfo.credentials;
79 provision_fix_subobj(subobj, paths);
81 info.session_info = session_info;
82 info.message = writefln;
85 /* Setup a basic database structure, but don't setup any users */
86 if (!provision(subobj, writefln, true, paths,
87 session_info, credentials, false)) {
88 writefln("Provision failed!");
91 } else if (!join_domain(form.DOMAIN, form.HOSTNAME, misc.SEC_CHAN_BDC, creds, writefln)) {
92 writefln("Domain Join failed!");
95 } else if (!vampire(form.DOMAIN, session.authinfo.session_info,
96 session.authinfo.credentials, writefln)) {
97 writefln("Failed to syncronsise remote domain into local database!");
98 } else if (!provision_dns(subobj, writefln, paths,
99 session.authinfo.session_info, session.authinfo.credentials)) {
100 writefln("DNS Provision failed!");
101 } else if (!(samdb = open_ldb(info, paths.samdb, false))) {
102 writefln("Opening " + paths.samdb + " failed!");
104 } else if (!setup_name_mappings(info, samdb)) {
105 writefln("Setup of name mappings failed!");
107 var zonepath = paths.dns;
109 <h3>Database migrated!</h3>
110 You need to do the following to complete the process:
112 <li>Install the <b>@@zonepath</b> zone file into your bind install, and restart bind
113 <li>Change your smb.conf to set "server role = domain controller"
114 <li>Shutdown your existing PDC and any other DCs