mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Refactored authorizers to classes * Merge changes for #7335 * ! fix php 5.3 incompatibility * Update ADAuthorizationAuthorizer.php * Fix get_user -> getUser * Rename AuthorizerFactory to Auth, fix interface missing functions * Add phpdocs to all interface methods and normalize the names a bit. * Re-work auth_test.php AD bind tests to work properly with the new class. Reflection is not the nicest tool, but I think it is appropriate here. Handle exceptions more nicely in auth_test.php * Restore AD getUseList fix Not sure how it got removed * fix auth_test.php style
38 lines
928 B
PHP
Executable File
38 lines
928 B
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/*
|
|
* LibreNMS
|
|
*
|
|
* This file is part of LibreNMS.
|
|
*
|
|
* @package LibreNMS
|
|
* @subpackage cli
|
|
* @copyright (C) 2006 - 2012 Adam Armstrong
|
|
*
|
|
*/
|
|
|
|
use LibreNMS\Authentication\Auth;
|
|
|
|
$init_modules = array();
|
|
if (php_sapi_name() != 'cli') {
|
|
$init_modules[] = 'auth';
|
|
}
|
|
require __DIR__ . '/includes/init.php';
|
|
|
|
if (Auth::get()->canManageUsers()) {
|
|
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
|
|
if (!Auth::get()->userExists($argv[1])) {
|
|
if (Auth::get()->addUser($argv[1], $argv[2], $argv[3], @$argv[4])) {
|
|
echo 'User '.$argv[1]." added successfully\n";
|
|
}
|
|
} else {
|
|
echo 'User '.$argv[1]." already exists!\n";
|
|
}
|
|
} else {
|
|
echo "Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n";
|
|
}
|
|
} else {
|
|
echo "Auth module does not allow adding users!\n";
|
|
}//end if
|