PHP/Authencate by NAS

From Fundamental Ramen
< PHP
Jump to navigation Jump to search
<?php
require_once 'vendor/autoload.php';

use Dapphp\Radius\Radius;

$username = '...';
$password = '...';
$host = '...';
$secret = '...';

$client = new Radius();
$client->setDebug(true);
$client->setServer($host)
       ->setSecret($secret);

$client->setMSChapPassword($password);
$authenticated = $client->accessRequest($username);

if ($authenticated === false) {
    echo sprintf(
        "Access-Request failed with error %d (%s).\n",
        $client->getErrorCode(),
        $client->getErrorMessage()
    );
} else {
    echo "Success!  Received Access-Accept response from RADIUS server.\n";
}