diff --git a/AUTHORS.md b/AUTHORS.md index 4c3d6983b..0b495e5b1 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -69,4 +69,5 @@ Contributors to LibreNMS: - Rob Gormley (rgormley) - Richard Kojedzinszky (rkojedzinszky) - Tony Murray (murrant) +- Peter Lamperud (vizay) [1]: http://observium.org/ "Observium web site" diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php index a562ae901..a1dd80f86 100644 --- a/html/includes/authentication/active_directory.inc.php +++ b/html/includes/authentication/active_directory.inc.php @@ -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); } } @@ -43,6 +44,7 @@ function authenticate($username, $password) { } else { // group membership is not required and user is valid + adduser($username); return 1; } } @@ -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;