147 lines
5.9 KiB
Perl
Executable File
147 lines
5.9 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
# makeusr.cgi
|
|
# ... Servicios de Tarantella.
|
|
# STTA Rev. 1.3 Copyright (c) 2001-2002 Jesús Pérez Lorenzo --- license GNU GPL
|
|
|
|
require './stta-lib.pl';
|
|
do "ldap-lib.pl";
|
|
|
|
&headerstta($text{'index_addusr'}, "", "",undef,1,1,$text{headpage_rigth} );
|
|
print "<hr><p>\n";
|
|
&foreign_require("proc", "proc-lib.pl");
|
|
&connect ();
|
|
&ReadParse();
|
|
|
|
$type_cmd = $in{ttacmd};
|
|
print "<p>\n";
|
|
print "<table width=100% border>\n";
|
|
print "<tr $tb> <td><b>$text{'titidx_adusr'}</b></td> </tr>\n";
|
|
print "<tr $cb> <td><table width=100%>\n";
|
|
print "<center>\n";
|
|
|
|
&connect ();
|
|
$ldap_base=$config{ldap_dnusers};
|
|
$filter = "(cn=*)";
|
|
|
|
&additional_log("search ", undef, "$ldap_base\nsubtree\n$filter");
|
|
$entry = $conn->search ($ldap_base, "subtree", $filter );
|
|
&ldapcache_logerr("search $ldap_base");
|
|
while ($entry) {
|
|
my (%users);
|
|
$users{dn} = $entry->getDN ();
|
|
$users{cn} = $entry->{cn}[0];
|
|
$users{displayname} = $entry->{displayname}[0];
|
|
$users[$numusrs++] = \%users;
|
|
$users{department} = $entry->{description}[0];
|
|
$entry = $conn->nextEntry ();
|
|
}
|
|
|
|
$username=$in{username};
|
|
$administrador=false;
|
|
$passwcache=true;
|
|
# $ntdomain=$config{'companyntdomain'};
|
|
$ntdomain="";
|
|
|
|
if ($username) {
|
|
$userou=$in{userou};
|
|
$password=$in{password};
|
|
$organizationname="";
|
|
$dn_ou="";
|
|
$ens_ou="";
|
|
%h_ou=&list_ous();
|
|
if ( $h_ou{$userou}->{'alias'} ne $userou ) {
|
|
$err_msg=$text{'list_err'};
|
|
&footHere;
|
|
exit;
|
|
}
|
|
$dn_ou=$h_ou{$userou}->{'obj'};
|
|
$organizationname=$h_ou{$userou}->{'name'};
|
|
$ens_ou=$h_ou{$userou}->{'ens'};
|
|
$dn = "cn=$username,$dn_ou,".$config{ldap_base};
|
|
$entry = $conn->newEntry ();
|
|
$entry->setDN ($dn);
|
|
$entry->{objectclass} =
|
|
["top", "person", "organizationalperson", "inetorgperson"];
|
|
$entry->{userpassword} = [$password];
|
|
$entry->{description} = [$organizationname];
|
|
$entry->{sn} = [$username];
|
|
$entry->{cn} = [$username];
|
|
$entry->{uid} = [$username];
|
|
$conn->add ($entry);
|
|
if ($err = $conn->getErrorCode ()) {
|
|
print "<hr>\n";
|
|
print "<b> Error: $username.</b>\n";
|
|
print "<hr>\n";
|
|
&ldap_logerr("add $dn");
|
|
}
|
|
else {
|
|
&ldap_logerr("add $dn");
|
|
&webmin_log("makeusr.cgi", "loadusr", "$dn $err");
|
|
$lin_user="add::".$username."::".$password."::".$username."::".$dn;
|
|
&lock_file($config{'ldap_log'});
|
|
open(FILELDAPLOG, ">>$config{'ldap_log'}");
|
|
print FILELDAPLOG "$lin_user\n";
|
|
close (FILELDAPLOG);
|
|
$str=$text{'user_made'}.$username." -> ".$dn;
|
|
&additional_log('makeusr.cgi', "loadusr", $str);
|
|
&webmin_log($config{'ldap_log'}, "loadusr", "write");
|
|
&unlock_file($config{'ldap_log'});
|
|
$| = 1;
|
|
$temp = &tempname();
|
|
open(TEMP, ">$temp");
|
|
print TEMP "#!/bin/sh\n";
|
|
print TEMP $env;
|
|
print TEMP "export $export\n" if ($export);
|
|
print TEMP "$str\n";
|
|
$ens_obj = "--name \"".$config{tta_base}."/$ens_ou/cn=$username\"";
|
|
$temp_f=$config{'tta_defaults_obj'};
|
|
%h_ttaobj=&load_ttaobj();
|
|
$user =$h_ttaobj{'user'}->{'value'};
|
|
$ntdomain =$h_ttaobj{'ntdomain'}->{'value'};
|
|
$bandwidth =$h_ttaobj{'bandwidth'}->{'value'};
|
|
$cdm =$h_ttaobj{'cdm'}->{'value'};
|
|
$enabled =$h_ttaobj{'enabled'}->{'value'};
|
|
$inherit =$h_ttaobj{'inherit'}->{'value'};
|
|
$shared =$h_ttaobj{'shared'}->{'value'};
|
|
$webtop =$h_ttaobj{'webtop'}->{'value'};
|
|
$conntype=$h_ttaobj{'conntype'}->{'value'};
|
|
$temp_f = &tempname();
|
|
open(TEMPF, ">$temp_f");
|
|
print TEMPF "$ens_obj\\\n";
|
|
print TEMPF " --surname \"$in{username}\" \\\n";
|
|
if ( $user ne "" ) {print TEMPF " --user \"$user\" \\\n"; }
|
|
if ( $ntdomain ne "" ) {print TEMPF " --ntdomain \"$ntdomain\"\\\n"; }
|
|
if ( $bandwidth ne "" ) {print TEMPF " --bandwidth \"$bandwidth\"\\\n"; }
|
|
if ( $cdm ne "" ) {print TEMPF " --cdm \"$cdm\"\\\n"; }
|
|
if ( $enabled ne "" ) {print TEMPF " --enabled \"$enabled\"\\\n"; }
|
|
if ( $shared ne "" ) {print TEMPF " --shared \"$shared\"\\\n"; }
|
|
if ( $inherit ne "" ) {print TEMPF " --inherit \"$inherit\"\\\n"; }
|
|
if ( $conntype ne "" ) { print TEMPF " --conntype \"$conntype\"\\\n"; }
|
|
if ( $webtop ne "" ) {print TEMPF " --webtop \"$webtop\"\\\n"; }
|
|
print TEMPF " --description \"$in{username}\" \n";
|
|
close(TEMPF);
|
|
|
|
if (&run_tta_cmd($type_cmd,$ens_obj,$temp_f)) {
|
|
print "<tr><p><b>".$text{'user_made'}.$username." -> ".$in{userou}."</b></tr>\n";
|
|
print "<tr></tr>\n";
|
|
print "<tr><form METHOD=POST name=addusr ACTION=\"tta_modusr.cgi?username=$username&userou=$userou\" >\n";
|
|
print " <input TYPE=\"hidden\" NAME=\"postform\" VALUE=\"addusr\"\n";
|
|
print " <input TYPE=\"hidden\" NAME=\"username\" VALUE=\"",$username,"\"\n";
|
|
print " <input TYPE=\"hidden\" NAME=\"userou\" VALUE=\"",$userou,"\">\n";
|
|
print " <input TYPE=\"hidden\" NAME=\"administrador\" VALUE=\"",$administrador,"\">\n";
|
|
print " <input TYPE=\"hidden\" NAME=\"dn\" VALUE=\"",$dn,"\">\n";
|
|
print " <input TYPE=\"hidden\" NAME=\"passwdcache\" VALUE=\"",$passwdcache,"\">\n";
|
|
print " <tr><td valign=top><input TYPE=\"submit\" NAME=\"",$text{'f_modatt'},"\" VALUE=\"",$text{'f_modatt'},"\">\n";
|
|
print " \n";
|
|
print " </form>\n";
|
|
}
|
|
unlink($temp_f);
|
|
}
|
|
}
|
|
print "<tr><tr></table></table><hr><p>\n";
|
|
&footer($config{'back_return'},$text{'index'});
|
|
print "<p><p><p>\n";
|
|
do "footer.pl";
|
|
exit;
|
|
|