mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #2434 from vizay/adauth_adduser_to_db
Ad-auth need to add user to db for dashboards to work properly
This commit is contained in:
@@ -69,4 +69,5 @@ Contributors to LibreNMS:
|
|||||||
- Rob Gormley <robert@gormley.me> (rgormley)
|
- Rob Gormley <robert@gormley.me> (rgormley)
|
||||||
- Richard Kojedzinszky <krichy@nmdps.net> (rkojedzinszky)
|
- Richard Kojedzinszky <krichy@nmdps.net> (rkojedzinszky)
|
||||||
- Tony Murray <murraytony@gmail.com> (murrant)
|
- Tony Murray <murraytony@gmail.com> (murrant)
|
||||||
|
- Peter Lamperud <peter.lamperud@gmail.com> (vizay)
|
||||||
[1]: http://observium.org/ "Observium web site"
|
[1]: http://observium.org/ "Observium web site"
|
||||||
|
@@ -35,6 +35,7 @@ function authenticate($username, $password) {
|
|||||||
if (isset($config['auth_ad_groups'][$group_cn]['level'])) {
|
if (isset($config['auth_ad_groups'][$group_cn]['level'])) {
|
||||||
// user is in one of the defined groups
|
// user is in one of the defined groups
|
||||||
$user_authenticated = 1;
|
$user_authenticated = 1;
|
||||||
|
adduser($username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ function authenticate($username, $password) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// group membership is not required and user is valid
|
// group membership is not required and user is valid
|
||||||
|
adduser($username);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,11 +83,20 @@ function auth_usermanagement() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function adduser() {
|
function adduser($username) {
|
||||||
// not supported so return 0
|
// Check to see if user is already added in the database
|
||||||
return 0;
|
if (!user_exists_in_db($username)) {
|
||||||
|
return dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function user_exists_in_db($username) {
|
||||||
|
$return = dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
function user_exists($username) {
|
function user_exists($username) {
|
||||||
global $config, $ds;
|
global $config, $ds;
|
||||||
|
Reference in New Issue
Block a user