summaryrefslogtreecommitdiffstats
path: root/source4/script/dcpromo.pl
blob: 56461ae8250ffa96c482618fdc962de5abb6a7f2 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/perl -w

###################################################
# package to generate samba ads configuration
# Copyright metze@samba.org 2004

# released under the GNU GPL

use strict;
use Data::Dumper;

sub print_options($$) {
	my $ads = shift;
	my $ctx = shift;
	my @arr;
	my $i;
	my $len;

	print "options:\n";

	@arr = @{$ctx};
	$len = $#arr;
	for($i = 0; $i <= $len; $i++) {
		my $val = $ctx->[$i];
		print "\t".$i.": ".$val->{TEXT}."\n";
	}

	print "choise []:";
}

sub read_option($$) {
	my $ads = shift;
	my $ctx = shift;
	my $val;

	$val = <STDIN>;

	return $val;
}

sub call_option($$$) {
	my $ads = shift;
	my $ctx = shift;
	my $switch = shift;
	my $val;
	my $funcref;

	$val = $ctx->[$switch];

	$funcref = $val->{ACTION};

	&$funcref($ads);
}

sub ask_option($$) {
	my $ads = shift;
	my $ctx = shift;
	my $ret;

	print_options($ads, $ctx);

	$ret = read_option($ads, $ctx);

	call_option($ads, $ctx, $ret);
}

sub create_ads_tree($) {
	my $ads = shift;

	print "Create ADS Domain:\n";
	print Dumper($ads);
}

sub do_new_domain_in_entire_structure($) {
	my $ads;
	my $domain_dns;
	my $domain_netbios;

	$ads->{NEW_DOMAIN} = 1;
	$ads->{NEW_FOREST} = 1;

	print "full dns name of the new domain []:";	
	$domain_dns = <STDIN>;
	chomp $domain_dns;
	$ads->{FULL_DNS_NAME} = $domain_dns;

	print "netbios name of the new domain []:";	
	$domain_netbios = <STDIN>;
	chomp $domain_netbios;
	$ads->{NETBIOS} = $domain_netbios;

	create_ads_tree($ads);
}

sub do_sub_domain_in_existing_structure($) {
	my $ads = shift;
	my $user_name;
	my $user_domain;
	my $user_password;
	my $top_dns;
	my $domain_dns;
	my $domain_netbios;
	my $db_folder;
	my $db_logs;
	my $sysvol_folder;
	my $admin_password1;
	my $admin_password2;

	$ads->{NEW_DOMAIN} = 1;
	$ads->{NEW_FOREST} = 0;

	print "User Name []:";
	$user_name = <STDIN>;
	chomp $user_name;
	$ads->{USER}{NAME} = $user_name;

	print "User Domain []:";
	$user_domain = <STDIN>;
	chomp $user_domain;
	$ads->{USER}{DOMAIN} = $user_domain;

	print "User Password []:";
	$user_password = <STDIN>;
	chomp $user_password;
	$ads->{USER}{PASSWORD} = $user_password;

	print "full dns name of the top domain []:";	
	$top_dns = <STDIN>;
	chomp $top_dns;
	$ads->{TOP_DNS_NAME} = $top_dns;

	print "suffix of the new domain []:";
	$domain_dns = <STDIN>;
	chomp $domain_dns;
	$ads->{FULL_DNS_NAME} = $domain_dns.".".$top_dns;

	print "netbios name of the new domain []:";
	$domain_netbios = <STDIN>;
	chomp $domain_netbios;
	$ads->{NETBIOS} = $domain_netbios;

	print "folder for database files []:";
	$db_folder = <STDIN>;
	chomp $db_folder;
	$ads->{DB_FOLDER} = $db_folder;

	print "folder for database logs []:";
	$db_logs = <STDIN>;
	chomp $db_logs;
	$ads->{DB_LOGS} = $db_logs;

	print "folder for SYSVOL []:";
	$sysvol_folder = <STDIN>;
	chomp $sysvol_folder;
	$ads->{SYSVOL_FOLDER} = $sysvol_folder;

	#
	# test DNS here
	#

	#
	# test mixed/native here
	#

	print "Administrator password []:";
	$admin_password1 = <STDIN>;
	chomp $admin_password1;
	print "retype Administrator password []:";
	$admin_password2 = <STDIN>;
	chomp $admin_password2;
	if ($admin_password1 eq $admin_password2) {
		$ads->{ADMIN_PASSWORD} = $admin_password1;
	} else {
		$ads->{ADMIN_PASSWORD} = "";
	}

	create_ads_tree($ads);
}

sub do_sub_structure_in_global_structure($) {
	print "go on with do_sub_structure_in_global_structure\n";
}

sub do_new_domain($) {
	my $ads = shift;
	my $ctx;
	
	$ctx->[0]{TEXT}		= "new domain in entire structure";
	$ctx->[0]{ACTION}	= \&do_new_domain_in_entire_structure;

	$ctx->[1]{TEXT}		= "sub domain in existing structure";
	$ctx->[1]{ACTION}	= \&do_sub_domain_in_existing_structure;

	$ctx->[2]{TEXT}		= "sub structure in global structure";
	$ctx->[2]{ACTION}	= \&do_sub_structure_in_global_structure;

	ask_option($ads ,$ctx);
}

sub do_existing_domain($) {
	print "go on with do existing domain\n";
}

sub ask_new_or_exist_domain($) {
	my $ads = shift;
	my $ctx;
	
	$ctx->[0]{TEXT}		= "new domain";
	$ctx->[0]{ACTION}	= \&do_new_domain;

	$ctx->[1]{TEXT}		= "existing domain";
	$ctx->[1]{ACTION}	= \&do_existing_domain;

	ask_option($ads, $ctx);
}

sub main {
	my $ads;

	$ads->{ADS_TREE} = 1;

	ask_new_or_exist_domain($ads);
}

main();