refactor: LDAP debug output (#8434)

* LDAP debug
Updated LDAP and AD docs
ldap protocol default to v3 (so we don't have to set it all the time).  If this fails it should revert to v2.
ad was using auth_ad_timeout incorrectly (1 I think)

* Add option to list all users.
This commit is contained in:
Tony Murray
2018-03-29 05:40:27 -05:00
committed by Neil Lathwood
parent 3fb7f76aea
commit 5c83aa1e28
4 changed files with 71 additions and 45 deletions

View File

@@ -3,10 +3,11 @@
use LibreNMS\Authentication\Auth;
$options = getopt('u:rdvh');
if (isset($options['h']) || !isset($options['u'])) {
$options = getopt('u:rldvh');
if (isset($options['h']) || (!isset($options['l']) && !isset($options['u']))) {
echo ' -u <username> (Required) username to test
-r Reauthenticate user, (requires previous web login with "Remember me" enabled)
-l List all users (checks that auth can enumerate all allowed users)
-d Enable debug output
-v Enable verbose debug output
-h Display this help message
@@ -14,15 +15,14 @@ if (isset($options['h']) || !isset($options['u'])) {
exit;
}
$test_username = $options['u'];
if (isset($options['d'])) {
$debug = true;
}
if (isset($options['v'])) {
// might need more options for other auth methods
$config['auth_ad_debug'] = 1; // active_directory
// Enable debug mode for auth methods that have it
$config['auth_ad_debug'] = 1;
$config['auth_ldap_debug'] = 1;
}
$init_modules = array('web', 'auth');
@@ -81,6 +81,14 @@ try {
}
}
if (isset($options['l'])) {
$users = $authorizer->getUserlist();
echo "Users: " . implode(', ', array_column($users, 'username')) . PHP_EOL;
echo "Total users: " . count($users) . PHP_EOL;
exit;
}
$test_username = $options['u'];
$auth = false;
if (isset($options['r'])) {
echo "Reauthenticate Test\n";