stta/stta/modusr.cgi
2021-10-01 20:35:43 +01:00

161 lines
6.2 KiB
Perl
Executable File

#!/usr/bin/perl
# modusr.cgi
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo --- license GNU GPL
# stta: (@#) 1.31051043346- [2004_01_29_102036]
require './stta-lib.pl';
if ( $config{'has_ldapusers'} eq "true" || $config{'is_ldapcache'} eq "true") {
do "ldap-lib.pl";
}
&headerstta($text{'index_moddusr'}, "", "moddusr",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" );
print "<hr><p>\n";
&foreign_require("proc", "proc-lib.pl");
&ReadParse();
$type_cmd = $in{ttacmd};
$userou=$in{userorg};
$maxsess=$in{maxsess};
$username="";
$dn="";
$sysuser = $in{sysuser};
$syncuser="";
$dn = $in{dn};
if (!$dn) { &redirect("tta_selusr.cgi?form=modusr"); }
$username = $in{username};
if ( $config{'has_systemusers'} eq "true" && $dn eq "-" && $sysuser ne "" ) {
$syncuser = $in{syncuser};
$username=$sysuser;
$dn="";
}
print "<p>\n";
print "<table width=100% border>\n";
$organizationname="";
$ens_ou="";
%h_ou=&list_ous();
if ( $h_ou{$userou}->{'alias'} ne $userou ) {
$err_msg=$text{'list_errno'};
&footHere;
exit;
}
$dn_ou=$h_ou{$userou}->{'obj'};
$organizationname=$h_ou{$userou}->{'name'};
$ens_ou=$h_ou{$userou}->{'ens'};
print "<table width=100% border>\n";
if ( $username ) {
print "<tr $tb> <td><font color='$revtext'><b>".&text('titidx_modusr',$username,$organizationname)."</b></td> </tr>\n";
} elsif ( $sysuser) {
print "<tr $tb> <td><font color='$revtext'><b>".&text('titidx_modusr',$sysuser,$organizationname)."</b></td> </tr>\n";
}
print "<tr $cb> <td><table width=100%>\n";
if ( $config{'has_ldapusers'} eq "true" && $username && $dn) {
$ldap_server=1;
&connect ();
if ( &mod_usr() eq 0 ) {
if ( $config{ldap2_server}.length gt 0 ) {
$ldap_server=2;
&connect ();
if ( &mod_usr() ne 0 ) { &err_replication() }
}
if ( $config{'ldap_log_name'} ne "" ) {
$lin_user="mod::".$username."::".$password."::".$in{surname}."::".$dn;
&lock_file($config{'ldap_log_name'});
open(FILELDAPLOG, ">>$config{'ldap_log_name'}");
print FILELDAPLOG "$lin_user\n";
close (FILELDAPLOG);
&unlock_file($config{'ldap_log_name'});
&remote_file("write",$config{ldap_log_name},"ldap_log_name");
}
$str=$text{'user_update'}.$username." -> ".$dn;
&additional_log('modusr.cgi', "usr", $str);
&webmin_log($config{'ldap_log_name'}, "usr", "modify");
print "<tr></tr><tr></tr>\n";
print "<tr $cb><td><b>".$text{'user_update'}."... LDAP ... </b></td></tr>\n";
} else { &html_errshow("ldap")};
}
if ( $username ) {
if ( $ens_ou eq "" ) {
$ens_obj = "cn=$username";
} else {
$ens_obj = "$ens_ou/cn=$username";
}
}
$| = 1;
print "<tr $cb><td><pre>\n";
$temp_f = &tempname();
$shared=$in{shared};
$inherit=$in{inherit};
$enabled=$in{enabled};
if ( $shared ne "false" && $shared ne "true" ) { $shared="false" }
if ( $inherit ne "false" && $inherit ne "true" ) { $inherit="false" }
open(TEMPF, ">$temp_f");
print TEMPF " --name \"".$config{tta_base}."/$ens_obj\" \\\n";
print TEMPF " --surname \"$in{surname}\" \\\n";
print TEMPF " --description \"$in{descrip}\"\\\n";
print TEMPF " --user \"$in{user}\"\\\n";
print TEMPF " --email \"$in{email}\"\\\n";
if ( $in{ntdomain} ne "" ) {
print TEMPF " --ntdomain \"$in{ntdomain}\"\\\n";
}
%h_webtops=&list_webtops();
$w=$in{webtop};
if ( $h_webtops{$w}->{'alias'} eq $w ) {
print TEMPF " --webtop \"$h_webtops{$w}->{'obj'}\"\\\n";
}
print TEMPF " --inherit \"$inherit\"\\\n";
print TEMPF " --shared \"$shared\"\\\n";
print TEMPF " --enabled \"$enabled\"\\\n";
if ( $conntype ne "" ) {
print TEMPF " --conntype \"$in{conntype}\"\\\n";
}
if ( $in{bandwidth} gt 0 ) {
print TEMPF " --bandwidth \"$in{bandwidth}\"\\\n";
}
print TEMPF " --cdm \"$in{cdm}\" \n";
close(TEMPF);
if (&run_tta_cmd($type_cmd,$ens_obj,$temp_f)) {
print "</pre><tr $cb><td><b>$text{'user_update'}... Tarantella </td></tr>\n";
} else { &html_errshow("tta")};
if ( $sysuser ne "" ) {
%h_sysusers=&list_sysusers();
$lin_sysuser=$sysuser."::".$userou."::".$ens_obj."::".$maxsess."::".$in{email}."::".$in{descrip}."::";
&out_objslist( "modify", "modusr.cgi", "sysusers", "sysusers_list", $sysuser, $lin_sysuser, \%h_sysusers );
if ( $in{syncuser} eq "true" ) { &make_remote_user("modify",$sysuser); }
}
# Default object para LDAP cache ...
if ( $config{'is_ldapcache'} eq "true" && $in{tta3tier_login} ) {
if ( $sysuser ne "" ) {
$dn_org = "ou=$sysuser";
} else {
$dn_org = "ou=$username";
}
if ( $dn_ou ne "" ) { $dn_org .= ",$dn_ou"; }
$dnldap = "default";
$default_obj="cn=$config{ldapcache_defaultobj}";
$dn_cache=$dn_org;
$task="mod";
$ldapcache_server=1;
&connect_cache();
$dn_wk=$default_obj.",".$dn_cache.",".$config{ldapcache_base};
$cur_entry=&sel_cache_obj($dn_wk,"cn=*");
if ( !defined($cur_entry) || $cur_entry->dn ne $dn_wk) { $task="add"; };
@tta3tier=&set_tta3tier($default_obj,$dn_cache,$dnldap,$task,"user");
if ( &cache_obj(\%tta3tier) eq 0 ) {
if ( $config{ldapcache2_server}.length gt 0 ) {
$ldapcache_server=2;
&connect_cache ();
if ( &cache_obj(\%tta3tier) ne 0 ) { &err_replication() }
}
} else { &html_errshow("ldap")};
}
if ( $debug lt 2 ) { unlink($temp_f); }
print "</tr></td></pre>\n";
print "<tr></tr>\n";
print "<tr><tr></table></table><hr><p>\n";
&footer($config{'back_return'},$text{'index'});
print "<p><p><p>\n";
do "footer.pl";
exit;