Created
April 23, 2025 02:45
-
-
Save virus-warnning/3e041ea8a6dea6474f733ee3e955b24a to your computer and use it in GitHub Desktop.
PHP 不使用 radius extension 完成認證
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment