Example #1
0
 /**
  * creates the default local user in datastore
  * @return boolean	true, if user was created
  *			false, if there were errors
  */
 public function createDefaultUser()
 {
     try {
         $localAuthProvider = new AuthenticationProviderLocal(null);
         $localAuthProvider->addUser("admin", "yourcmdb", "admin");
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Example #2
0
* WebUI element: manage local users
* @author Michael Batz <*****@*****.**>
*/
//imports
use yourCMDB\security\AuthenticationProviderLocal;
use yourCMDB\security\SecurityChangeUserException;
use yourCMDB\exceptions\CmdbLocalUserAlreadyExistsException;
use yourCMDB\exceptions\CmdbLocalUserNotFoundException;
//include base
include "../include/bootstrap-web.php";
//authentication and authorisation
$authorisationAppPart = "admin";
include "../include/auth.inc.php";
include "../include/authorisation.inc.php";
//central objects
$authProviderLocal = new AuthenticationProviderLocal(null);
//execute actions if required
$action = getHttpGetVar("action", "");
switch ($action) {
    case "addUser":
        $username = getHttpGetVar("username", "");
        $password = getHttpGetVar("password", "");
        $accessgroup = getHttpGetVar("accessgroup", "");
        try {
            $result = $authProviderLocal->addUser($username, $password, $accessgroup);
            if ($result) {
                printInfoMessage(sprintf(gettext("user %s successfully created"), $username));
            } else {
                printErrorMessage(sprintf(gettext("Error creating user  %s"), $username));
            }
        } catch (SecurityChangeUserException $e) {