如何修复PHP中的“无法理解请求”错误

时间:2019-01-17 16:50:51

标签: php button active-directory

我正在使用Active Directory by Magium来获取我的应用程序的AD连接​​。 当我单击按钮运行身份验证功能时,它不会将我重定向到Microsoft登录页面,而是显示以下php错误:

  

致命错误:未捕获的Magium \ ActiveDirectory \ InvalidRequestException:   无法理解中的请求   C:\ inetpub \ Timesheets \ vendor \ magium \ active-directory \ src \ ActiveDirectory.php:181   堆栈跟踪:#0 C:\ inetpub \ Timesheets \ functions.php(33):   Magium \ ActiveDirectory \ ActiveDirectory-> authenticate()#1   C:\ inetpub \ Timesheets \ index.php(9):   loginAction(Object(Magium \ ActiveDirectory \ ActiveDirectory))#2 {main}   扔进去   C:\ inetpub \ Timesheets \ vendor \ magium \ active-directory \ src \ ActiveDirectory.php   在第181行

我正在PHP7.1上运行它,并且它在过去一直有效,我在这里一定做错了,但是我似乎找不到任何东西。

此刻我正在处理两个文件,一个是我的functions.php

require_once __DIR__ . '.\vendor\autoload.php';

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$config = [
    'authentication' => [
        'ad' => [
            'client_id' => 'My-ID',
            'client_secret' => 'My-Secret',
            'enabled' => 'yes',
            'directory' => 'common'
        ]
    ]
];

$request = new \Zend\Http\PhpEnvironment\request();
$ad = new \Magium\ActiveDirectory\ActiveDirectory(
    new \Magium\Configuration\Config\Repository\ArrayConfigurationRepository($config),
    Zend\Psr7Bridge\Psr7ServerRequest::fromZend(new \Zend\Http\PhpEnvironment\request())
);

    function loginAction($ad)
    {
        $ad->authenticate();
    };

另一个是索引,用户应该可以从该索引登录:

require_once __DIR__ . '.\vendor\autoload.php';
include 'functions.php';

session_start();


if(isset($_POST['login'])) {
    loginAction($ad);
}

?>
<body>
<div class="box">
    <header>
        <p>Welkom op de timesheet applicatie.</p>
        <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
            <input type="submit" name="login" value="Login" class="myButton" />
        </form>
    </header>

我希望当我的用户单击按钮时,他们被重定向到Microsoft登录页面,并在登录后被重定向回该主页。

0 个答案:

没有答案