#!/usr/bin/perl
# tta_delhostsuser.cgi
# Delete Hosts Group Users from Tarantella Services

 require './tarantella-lib.pl';
&foreign_require("proc", "proc-lib.pl");
do "ldap-lib.pl";
&ReadParse();

 $hostsusername=$in{hostsusername};
 &header($text{'index_delhostsuser'}, "", "");
 print "<hr><p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_delhostsuser'} $hostusername </b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<center>\n";

if ($hostsusername ) {
              print "<tr></tr><tr></tr>\n";
              print "</pre><tr><p><b>$text{'user_delete'}... Tarantella </b></tr>\n";
                      @lista_hostsuser=&list_hostsuser();
                      &lock_file($config{'hostsuser_list'});
	              open(FILEHOSTSUSER, ">$config{'hostsuser_list'}");
                      foreach $hostsuser (@lista_hostsuser) {
                         if ( $hostsuser->{'username'} ne $hostsusername) {
                             $lin_hostsuser=$hostsuser->{'username'}."::".$hostsuser->{'passwd'}."::".$hostsuser->{'name'}."\n";
                             print FILEHOSTSUSER "$lin_hostsuser";
                            
                         }
                      }
                      close (FILEHOSTSUSER);
                      $str=$text{'user_delete'}.$hostsusername;
                      &additional_log('delhostsuser.cgi', undef, $str);
                      &webmin_log($config{'hostsuser_list'}, undef, "delete");
                      &unlock_file($config{'hostsuser_list'});
              print "</tr></td></pre>\n";
}
 print "<tr><tr></table></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;
