Same fix as bug 8989 - Samba 3.5.x (and probably all other versions of Samba) does...
[Samba.git] / swat2 / install / vampire.esp
blob77e9959de32f7ca87dc308969d562f1619b9eaec
1 <% page_header("columns", "Windows to Samba Migration", "install"); 
3   include("/scripting/forms.js");
4   libinclude("base.js");
5   libinclude("provision.js");
7   var misc = misc_init();
8 %>
10 <h1>Windows to Samba4 domain migration</h1>
13 var f = FormObj("Provisioning", 0, 2);
14 var i;
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");
22         }
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") {
40                 redirect("/");
41         }
43         if (form['submit'] == "Migrate") {
44                 for (r in form) {
45                         subobj[r] = form[r];
46                 }
47         }
48         
49         for (i=0;i<f.element.length;i++) {
50                 f.element[i].value = subobj[f.element[i].name];
51         }
52         
53         if (form['submit'] == "Migrate") {
54                 /* overcome an initially blank smb.conf */
55                 lp.set("realm", subobj.REALM);
56                 lp.set("workgroup", subobj.DOMAIN);
57                 lp.reload();
59                 if (subobj.ADMINPASS == "") {
60                         write("<h3>We need the administrator password for the " + subobj.DOMAIN + " domain to proceed.  Please try again.</h3>");
61                         f.display();
62                 } else if (!provision_validate(subobj, writefln)) {
63                         f.display();
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");
66                 } else {
67                         var creds = credentials_init();
68                         var samdb;
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);
80                 
81                         info.session_info = session_info;
82                         info.message = writefln;
83                         info.subobj = subobj;
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!");
90                                 /* Join domain */
91                         } else if (!join_domain(form.DOMAIN, form.HOSTNAME, misc.SEC_CHAN_BDC, creds, writefln)) {
92                                 writefln("Domain Join failed!");
93                         
94                                 /* Vampire */
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!");
103                                 info.samdb = samdb;
104                         } else if (!setup_name_mappings(info, samdb)) {
105                                 writefln("Setup of name mappings failed!");                     
106                         } else {
107                                 var zonepath = paths.dns;
108                                 %>
109 <h3>Database migrated!</h3>
110 You need to do the following to complete the process:
111 <ul>
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
115         <li>Restart smbd
116 </ul>
118                         }
119                 }
120         } else {
121                 f.display();
122         }
123 } else {
124         redirect("/");
130 <% page_footer(); %>