Skip to content

Commit

Permalink
Merge pull request #2434 from vizay/adauth_adduser_to_db
Browse files Browse the repository at this point in the history
Ad-auth need to add user to db for dashboards to work properly
  • Loading branch information
laf committed Nov 17, 2015
2 parents a6f34fd + f9c6941 commit 6e1e6b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ Contributors to LibreNMS:
- Rob Gormley <robert@gormley.me> (rgormley)
- Richard Kojedzinszky <krichy@nmdps.net> (rkojedzinszky)
- Tony Murray <murraytony@gmail.com> (murrant)
- Peter Lamperud <peter.lamperud@gmail.com> (vizay)
[1]: http://observium.org/ "Observium web site"
17 changes: 14 additions & 3 deletions html/includes/authentication/active_directory.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function authenticate($username, $password) {
if (isset($config['auth_ad_groups'][$group_cn]['level'])) {
// user is in one of the defined groups
$user_authenticated = 1;
adduser($username);
}
}

Expand All @@ -43,6 +44,7 @@ function authenticate($username, $password) {
}
else {
// group membership is not required and user is valid
adduser($username);
return 1;
}
}
Expand Down Expand Up @@ -81,11 +83,20 @@ function auth_usermanagement() {
}


function adduser() {
// not supported so return 0
return 0;
function adduser($username) {
// Check to see if user is already added in the database
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) {
global $config, $ds;
Expand Down

0 comments on commit 6e1e6b6

Please sign in to comment.