[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/scripts/ -> delHome.pl (source)

   1  #!/usr/bin/perl
   2  
   3  use Net::LDAP;
   4  use DBI;
   5  
   6  require '/etc/SeConfig.ph';
   7  
   8  $LCS = 1 if shift @ARGV;
   9  $lcs_db = DBI->connect('DBI:mysql:lcs_db', $mysqlServerUsername, $mysqlServerPw) if $LCS;
  10  
  11  # Suppression des comptes utilisateurs
  12  $lcs_ldap = Net::LDAP->new("$slapdIp");
  13  $lcs_ldap->bind(); # Anonyme
  14             # dn       => $adminDn,
  15             # password => $adminPw,
  16             # version  => '3'
  17             # );
  18  $res = $lcs_ldap->search(base   => "ou=Trash,$baseDn",
  19               scope  => 'one',
  20               filter => 'uid=*');
  21  warn $res->error if $res->code;
  22  foreach $entry ($res->entries) {
  23    $uid = $entry->get_value('uid');  
  24    next if $uid =~ /^\s/;
  25    if (-d "/home/$uid") {  
  26        system("rm -r /home/$uid");
  27        #print "le rep /home/$uid existe\n";
  28    }    
  29    # Recherche du nom de la base données.
  30    $db_name = $uid;
  31    $db_name =~ s/-//g;
  32    $db_name =~ s/_//g;
  33    $db_name =~ s/\.//g;
  34    $db_name .= "_db";
  35    if ($LCS) {
  36      system("mysqladmin -f -u $mysqlServerUsername -p$mysqlServerPw drop $db_name > /dev/null 2>&1");
  37      $requete = $lcs_db->prepare("delete from personne where login = '$uid'");
  38      $requete->execute();
  39    }
  40  }
  41  $lcs_ldap->unbind;


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1