summaryrefslogtreecommitdiff
path: root/swat/install/vampire.esp
blob: 19f99dce98d0bbc8ba2b470b80f209a5e0335fb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<% page_header("columns", "Windows to Samba Migration", "install"); 

  include("/scripting/forms.js");
  libinclude("base.js");
  libinclude("provision.js");

  var misc = misc_init();
%>

<h1>Windows to Samba4 domain migration</h1>

<%
var f = FormObj("Provisioning", 0, 2);
var i;
var lp = loadparm_init();

if (lp.get("realm") == "") {
	lp.set("realm", lp.get("workgroup") + ".example.com");
}


var subobj = provision_guess();
/* Don't supply default password for web interface */
subobj.ADMINPASS = "";

f.add("REALM", "DNS Domain Name");
f.add("DOMAIN", "NetBIOS Domain Name");
f.add("ADMIN", "Administrator Username");
f.add("ADMINPASS", "Administrator Password", "password");
f.add("HOSTNAME", "My Hostname");
f.add("HOSTIP", "My Host's IP");
f.add("DEFAULTSITE", "Default Site");
f.submit[0] = "Migrate";
f.submit[1] = "Cancel";

if (form['submit'] == "Cancel") {
	redirect("/");
}

if (form['submit'] == "Migrate") {
	for (r in form) {
		subobj[r] = form[r];
	}
}

for (i=0;i<f.element.length;i++) {
	f.element[i].value = subobj[f.element[i].name];
}

if (form['submit'] == "Migrate") {
	lp.set("realm", subobj.REALM);
	if (subobj.ADMINPASS == "") {
		write("<h3>We need the administrator password for the " + subobj.DOMAIN + " domain to proceed.  Please try again.</h3>");
		f.display();
	} else if (!provision_validate(subobj, writefln)) {
		f.display();
	} else {
		var creds = credentials_init();
		creds.set_username(form.ADMIN);
		creds.set_password(form.ADMINPASS);
		creds.set_domain(form.DOMAIN);
		creds.set_realm(form.REALM);

		var paths = provision_default_paths(subobj);

		/* Setup a basic database structure, but don't setup any users */
		if (!provision(subobj, writefln, true, paths,
			       session.authinfo.session_info, session.authinfo.credentials)) {
			writefln("Provision failed!");

		/* Join domain */
		} else if (!join_domain(form.DOMAIN, form.HOSTNAME, misc.SEC_CHAN_BDC, creds, writefln)) {
			writefln("Domain Join failed!");
			
                /* Vampire */
		} else if (!vampire(form.DOMAIN, session.authinfo.session_info, 
					    session.authinfo.credentials, writefln)) {
			writefln("Failed to syncronsise remote domain into local database!");
		} else if (!provision_dns(subobj, writefln, paths,
					  session.authinfo.session_info, session.authinfo.credentials)) {
			writefln("DNS Provision failed!");
		} else {
			writefln("Migration Complete!");
		}
	}
} else {
	f.display();
}
%>


<% page_footer(); %>