r12928: This patch improves the interaction between the vampire and provsion code.
[kai/samba.git] / swat / 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 {
58                 var creds = credentials_init();
59                 creds.set_username(form.ADMIN);
60                 creds.set_password(form.ADMINPASS);
61                 creds.set_domain(form.DOMAIN);
62                 creds.set_realm(form.REALM);
63
64                 var paths = provision_default_paths(subobj);
65
66                 /* Setup a basic database structure, but don't setup any users */
67                 if (!provision(subobj, writefln, true, paths,
68                                session.authinfo.session_info, session.authinfo.credentials)) {
69                         writefln("Provision failed!");
70
71                 /* Join domain */
72                 } else if (!join_domain(form.DOMAIN, form.HOSTNAME, misc.SEC_CHAN_BDC, creds, writefln)) {
73                         writefln("Domain Join failed!");
74                         
75                 /* Vampire */
76                 } else if (!vampire(form.DOMAIN, session.authinfo.session_info, 
77                                             session.authinfo.credentials, writefln)) {
78                         writefln("Failed to syncronsise remote domain into local database!");
79                 } else if (!provision_dns(subobj, writefln, paths,
80                                           session.authinfo.session_info, session.authinfo.credentials)) {
81                         writefln("DNS Provision failed!");
82                 } else {
83                         writefln("Migration Complete!");
84                 }
85         }
86 } else {
87         f.display();
88 }
89 %>
90
91
92 <% page_footer(); %>