PHP/Authencate by NAS: Difference between revisions

From Fundamental Ramen
< PHP
Jump to navigation Jump to search
(Created page with "<?php require_once 'vendor/autoload.php'; <syntaxhighlight lang="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",...")
(No difference)

Revision as of 15:19, 18 April 2025

<?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";
}