예제 #1
0
 public function testBindAnonymous()
 {
     $ldap = new Ldap($this->container);
     self::$functions->expects($this->once())->method('ldap_bind')->with($this->equalTo('my_ldap_connection'), $this->equalTo(null), $this->equalTo(null))->will($this->returnValue(true));
     $this->assertTrue($ldap->bind('my_ldap_connection', 'my_user', 'my_password', 'anonymous'));
 }
예제 #2
0
if (array_key_exists('login', $_POST)) {
    $usuario = $_POST['login'];
    $conn = new Ldap();
    $result = $conn->search($base_dn, "uid={$_POST['login']}", array('cn', 'employeeNumber'));
    $entry = $result->first();
    $user_dn = $result->entry_dn();
    $user_pw = $_POST['senha'];
    /**
     * Faz o login e incia a sessao
     * Informaçoes disponiveis na sessao:
     * $_SESSION['usuarioNome'] --> Nome completo do Usuario (Fonte: Ldap)
     * $_SESSION['siape'] -> SIAPE do servidor (Fonte: Ldap)
     * $_SESSION['usuario'] -> login do usuario (mesmo do E-mail institucional)
     *
     */
    if ($conn->bind($user_dn, $user_pw)) {
        $_SESSION['usuarioNome'] = $entry['cn'][0];
        $_SESSION['siape'] = $entry['employeeNumber'][0];
        //  $_SESSION['siape'] ="390111";
        $_SESSION['usuario'] = $usuario;
        /*$_SESSION['usuario'] = 'arfonseca';*/
        header('location: /ponto/index.php');
        exit;
    } else {
        $msg = 'Usuario ou senha inválido!';
    }
}
?>
 <!DOCTYPE html> <html lang="en">
    <head>
        <meta charset="utf-8">