r20689: "pdc" and "bdc" have been replaced by "domain controller"
[jelmer/samba4-debian.git] / webapps / install / vampire.esp
1 <% page_header("columns", "Windows to Samba Migration", "install"); 
2
3   include("/scripting/forms.js");
4   libinclude("base.js");
5   libinclude("provision.js");
6
7   var misc = misc_init();
8 %>
9
10 <h1>Windows to Samba4 domain migration</h1>
11
12 <%
13 var f = FormObj("Provisioning", 0, 2);
14 var i;
15 var lp = loadparm_init();
16
17 if (lp.get("realm") == "") {
18         lp.set("realm", lp.get("workgroup") + ".example.com");
19 }
20
21
22 var subobj = provision_guess();
23 /* Don't supply default password for web interface */
24 subobj.ADMINPASS = "";
25
26 f.add("REALM", "DNS Domain Name");
27 f.add("DOMAIN", "NetBIOS Domain Name");
28 f.add("ADMIN", "Administrator Username");
29 f.add("ADMINPASS", "Administrator Password", "password");
30 f.add("HOSTNAME", "My Hostname");
31 f.add("HOSTIP", "My Host's IP");
32 f.add("DEFAULTSITE", "Default Site");
33 f.submit[0] = "Migrate";
34 f.submit[1] = "Cancel";
35
36 if (form['submit'] == "Cancel") {
37         redirect("/");
38 }
39
40 if (form['submit'] == "Migrate") {
41         for (r in form) {
42                 subobj[r] = form[r];
43         }
44 }
45
46 for (i=0;i<f.element.length;i++) {
47         f.element[i].value = subobj[f.element[i].name];
48 }
49
50 if (form['submit'] == "Migrate") {
51         lp.set("realm", subobj.REALM);
52         if (subobj.ADMINPASS == "") {
53                 write("<h3>We need the administrator password for the " + subobj.DOMAIN + " domain to proceed.  Please try again.</h3>");
54                 f.display();
55         } else if (!provision_validate(subobj, writefln)) {
56                 f.display();
57         } else if (strupper(lp.get("server role")) == "domain controller") {
58                 writefln("You need to set 'server role' to 'member server' before starting the migration process");
59         } else {
60                 var creds = credentials_init();
61                 var samdb;
62                 creds.set_username(form.ADMIN);
63                 creds.set_password(form.ADMINPASS);
64                 creds.set_domain(form.DOMAIN);
65                 creds.set_realm(form.REALM);
66
67                 var info = new Object();
68                 var paths = provision_default_paths(subobj);
69                 var session_info = session.authinfo.session_info;
70                 var credentials = session.authinfo.credentials;
71
72                 info.credentials = credentials;
73                 info.session_info = session_info;
74                 info.message = writefln;
75                 info.subobj = subobj;
76
77                 /* Setup a basic database structure, but don't setup any users */
78                 if (!provision(subobj, writefln, true, paths,
79                                session_info, credentials)) {
80                         writefln("Provision failed!");
81
82                 /* Join domain */
83                 } else if (!join_domain(form.DOMAIN, form.HOSTNAME, misc.SEC_CHAN_BDC, creds, writefln)) {
84                         writefln("Domain Join failed!");
85                         
86                 /* Vampire */
87                 } else if (!vampire(form.DOMAIN, session.authinfo.session_info, 
88                                             session.authinfo.credentials, writefln)) {
89                         writefln("Failed to syncronsise remote domain into local database!");
90                 } else if (!provision_dns(subobj, writefln, paths,
91                                           session.authinfo.session_info, session.authinfo.credentials)) {
92                         writefln("DNS Provision failed!");
93                 } else if (!(samdb = open_ldb(info, paths.samdb, false))) {
94                         writefln("Opening " + paths.samdb + " failed!");
95                         info.samdb = samdb;
96                 } else if (!setup_name_mappings(info, samdb)) {
97                         writefln("Setup of name mappings failed!");                     
98                 } else {
99                         var zonepath = paths.dns;
100                         %>
101 <h3>Database migrated!</h3>
102
103 You need to do the following to complete the process:
104
105 <ul>
106 <li>Install the <b>@@zonepath</b> zone file into your bind install, and restart bind
107 <li>Change your smb.conf to set "server role = domain controller"
108 <li>Shutdown your existing PDC and any other DCs
109 <li>Restart smbd
110 </ul>
111                         <%
112                 }
113         }
114 } else {
115         f.display();
116 }
117 %>
118
119
120 <% page_footer(); %>