require_once 'HTML_DietMarco.php';
require_once 'HTML_Login.php';
require_once 'MECON/Usuario.php'; //Agregado MANAZAR
if(isset($_POST['usuario']))
{
$userid = $_POST['usuario'];
$ds = @ldap_connect( 'ldapdist.mecon.ar' )
or $ds = @ldap_connect( 'ldapmaster.mecon.ar' );
if (! $ds) {
//error connecting - return false
echo "Error conectando!\n";
}
@ list( $uid, $domain ) = split( "@", $userid );
if(is_null($uid) || is_null($domain))
$error = true;
$r = @ ldap_bind($ds, "uid=$uid,ou=Personas,o=$domain,o=gov.ar", $_POST['password']);
if ($r) {
$sr = @ ldap_search($ds, "ou=Personas,o=$domain,o=gov.ar", "uid=$uid");
$info = @ ldap_get_entries($ds, $sr);
}
else
$error = true;
ldap_close($ds);
if (! @ $sr) {
//error reading / authenticating - return false
$error = true;
}
else
{
if(! @ $_POST['usuario'] || ! @ $info[0]['uidnumber'][0])
$error = true;
else
{
$_SESSION['usuario'] = $_POST['usuario'];
$_SESSION['documento'] = $info[0]['uidnumber'][0];
// Agregado por culpa de Aldoros
$aux = split('-',$_SESSION['documento']);
$_SESSION['documento'] = (count($aux) == 3) ? $aux[1] : $aux[0];
// Agregado MANAZAR
$MECON_DNI= $info[0]['uidnumber'][0];
$MECON_NOMBRE= $info[0]['sn'][0]." ".$info[0]['givenname'][0];
$MECON_LOGIN= $_POST['usuario'];
$usuario=& new MECON_USUARIO($DB);
$usuario->Insertar_Usuario($MECON_DNI,$MECON_LOGIN,$MECON_NOMBRE);
// Fin Agregado MANAZAR
}
}
}
{
if(!isset($_SESSION['usuario']) )
{
if (@$_REQUEST['redirect'] == 'sistemas' || @$_REQUEST['embperl']) {
$m = new HTML_DietMarco('sistemas', 'Sistemas');
// $m->addTitle('Sistemas');
}
else
{
$m = new HTML_DietMarco('servicios', 'Servicios');
// $m->addTitle('Servicios');
}
$login = new HTML_Login();
if(isset($error) && $error == 1)
$login->login_incorrecto = true;//FIXME terminar de prgramar cuando haya ldap
$t = new HTML_Table(array('width' => 760,
'align' => 'center',
'cellspacing' => 0,
'cellpadding' => 0,
'border' => 0,
'valign' => 'middle',
'height' => 200));
$t->addRow(array($login));
$m->addStyleSheet($login->getCSS());
$m->addBodyContent($t);
$m->display();
}
}
if(isset($_SESSION['usuario']) && ! @ $error &&
(@$_REQUEST['redirect']))
{
$redirect = $_REQUEST['redirect'];
$query = "SELECT link
FROM servicio
WHERE servicio = $redirect";
$link = $DB->getOne($query);
if(PEAR::isError($link)) {
if (@$_REQUEST['embperl']) {
header('Location: /Php2Embperl_Session?redirect='.$redirect);
}
else {
header('Location: '.$redirect);
}
}
else
header('location: '.$link);
}
?>