-
Notifications
You must be signed in to change notification settings - Fork 3
/
delete_users.php
73 lines (52 loc) · 1.54 KB
/
delete_users.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
<?php
/* generate default config */
include('conf.inc.php.init');
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");
$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 delete_user($username) {
$ldap=new LDAP();
$user=$ldap->get_user($username);
if ( ! $user ){
echo (" El usuario '$username' no existe.\n");
return;
}
if ( $user->delUser($deleteprofile) )
echo ("Usuario '$username' borrado.\n");
}
$prefix="alumno";
for($i=1; $i<1013; $i++) {
delete_user("$prefix$i");
}
die("fin\n");