-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate_hosts.php
78 lines (60 loc) · 1.71 KB
/
create_hosts.php
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
<?php
/* generate default config */
include('/etc/max-control/conf.inc.php');
include('modules/common.inc.php');
class GUI {
function debug($txt) {
if($txt == '') return;
//fwrite(STDERR, "D: ".print_r($txt, true)." \n");
}
function debuga($txt) {
if($txt == '') return;
//fwrite(STDERR, "D: ".print_r($txt, true)." \n");
}
function session_info($txt) {
$this->debug("SESSION INFO: ".$txt);
}
function session_error($txt) {
$this->debug("SESSION ERROR:".$txt);
}
}
$gui = new GUI();
include("classes/ldap.class.php");
include("classes/winexe.class.php");
/*
$LDAP_BASEDN=readLDAPFile('/etc/ldap.conf', 'base');
define('LDAP_BASEDN', $LDAP_BASEDN);
$LDAP_BINDDN=readLDAPFile('/etc/ldap.conf', 'rootbinddn');
define('LDAP_BINDDN', $LDAP_BINDDN);
$LDAP_BINDPW=file_get_contents('/etc/ldap.secret');
define('LDAP_BINDPW', $LDAP_BINDPW);
*/
/* usuario creado por max-control */
/*
define('LDAP_ADMIN', '$LDAP_ADMIN');
define('LDAP_PASS', '$LDAP_PASS');
*/
/*
exec("net getdomainsid | grep domain", $output);
$parts = preg_split ("/\s+/", $output[0]);
$LDAP_DOMAIN=$parts[3];
define('LDAP_DOMAIN', $LDAP_DOMAIN);
*/
$LDAP_ADMIN='max-control';
$LDAP_PASS=createPassword();
function create_host($hostname, $i) {
$ldap=new LDAP();
$data=Array("hostname" => $hostname,
"ipHostNumber"=> "192.168.1.1$i",
"macAddress" => "08:00:27:fc:4f:$i");
$computer=new COMPUTER();
if ( $computer->newComputer($data) )
echo "Equipo '$hostname' creado\n";
else
echo "No se pudo crear el equipo '$hostname'\n";
}
$prefix="pc";
for($i=1; $i<10; $i++) {
create_host("$prefix$i", $i);
}
die("fin\n");