creating the default administrator.
350147
def run_create_admin(*args):
    '''
    
    '''
    post_data = {
        'user_name': 'giser',
        'user_email': 'giser@osgeo.cn',
        'user_pass': '131322',
        'role': '3300',
    }
    if MUser.get_by_name(post_data['user_name']):
        print('User {user_name} already exists.'.format(user_name='giser'))
    else:
        MUser.create_user(post_data)
1285514
public function run()
    {
        Model::unguard();

        $role_admin = new Role();
        $role_admin->name = 'admin';
        $role_admin->description = 'Administrator';
        $role_admin->save();

        $role_editor = new Role();
        $role_editor->name = 'editor';
        $role_editor->description = 'An editor';
        $role_editor->save();
    }
477042
def initialize_options(self):
        """"""
        # Each user option must be listed here with their default value.
        self.debug = False
        self.ignore_errors = False
        self.distros = ''
        self.conductor_provider = 'ansible'
1064292
public function createAdministratorController()
    {
        $controller = $this->directory.'/Controllers/AdministratorController.php';
        $contents = $this->getStub('AdministratorController');

        $this->laravel['files']->put(
            $controller,
            str_replace('DummyNamespace', Admin::controllerNamespace(), $contents)
        );
        $this->line(
            '<info>AdministratorController file was created:</info> '.str_replace(base_path(), '', $controller)
        );
    }
396774
def admin(self):
        """"""
        if self._securityHandler is None:
            raise Exception("Cannot connect to adminstrative server without authentication")
        from ..manageags import AGSAdministration
        return AGSAdministration(url=self._adminUrl,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port,
                                 initialize=False)
352024
private static PrincipalUser createAdminUser() {
        PrincipalUser result = new PrincipalUser("admin", "argus-admin@salesforce.com");

        result.id = BigInteger.ONE;
        result.setPrivileged(true);
        return result;
    }
517783
def create_user(name, groups=None, key_file=None):
    """"""

    groups = groups or []
    if not user_exists(name):
        for group in groups:
            if not group_exists(group):
                sudo(u"addgroup %s" % group)
        groups = groups and u'-G %s' % u','.join(groups) or ''
        sudo(u"useradd -m %s -s /bin/bash %s" % (groups, name))
        sudo(u"passwd -d %s" % name)
    if key_file:
        sudo(u"mkdir -p /home/%s/.ssh" % name)
        put(key_file, u"/home/%s/.ssh/authorized_keys" % name, use_sudo=True)
        sudo(u"chown -R %(name)s:%(name)s /home/%(name)s/.ssh" % {'name': name})
853435
def populate_with_defaults():
    '''
    '''
    logging.getLogger(__name__).debug("Populating with default users")
    if not User.select().where(User.name == 'admin').exists():
        admin = User.create(name='admin', password='admin')
        admins = Group.create(name='admins')
        starCap = Capability.create(domain='.+',
                                    action=(Action.CREATE |
                                            Action.READ |
                                            Action.UPDATE |
                                            Action.DELETE))
        admins.capabilities.add(starCap)
        admin.groups.add(admins)
        admin.save()
    if not User.select().where(User.name == 'anonymous').exists():
        anon = User.create(name='anonymous', password='')
        anons = Group.create(name='anonymous')
        readCap = Capability.create(domain=Capability.simToReg('/volumes/*'),
                                    action=Action.READ)
        anons.capabilities.add(readCap)
        anon.groups.add(anons)
        anon.save()
883716
def set_default_command(self, command):
        """"""
        cmd_name = command.name
        self.add_command(command)
        self.default_cmd_name = cmd_name
66276
public function recreateDefaults()
    {
        // Administrator group
        /** @var AdminUserGroup $group */
        $group = AdminUserGroupRepository::findOneEntityById(1);

        // If no any Admin group - create new empty group
        if (!$group || !$group->getUndeletable() || !$group->getCanSetPermissions() || !$group->getFullAccess()) {
            if ($group) {
                $group->is_super_admin = true;
                $group
                    ->setField('undeletable', 1)
                    ->setField('can_set_permissions', 1)
                    ->setField('structure_permissions', 1)
                    ->setFullAccess(1)
                    ->save();
            } else {

                // Delete all groups
                $group_collection = new AdminUserGroupRepository();
                $group_collection->deleteObjectCollection();

                // Drop auto-increment value
                $group_collection->alterTableResetAutoIncrement();

                // Create new Group for Admins
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 1,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Developers',
                    ]
                );
                $group->save();

                // Create new Group for Managers
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 0,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Managers',
                        'default'               => 1,
                    ]
                );
                $group->save();

                echo '<br>Default User Group is created.<br>';
            }
        }

        unset($data);

        // Check we have any active Admin
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $have_any_user = $users_collection->hasAnyObjectInCollection();

        // Check we have admin as first User
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $users_collection->setWhereId(1);
        $users_collection->setWhereGroupId(1);
        $users_collection->setWhereLogin('neTpyceB'); // Name of vendor repo owner
        $have_default_user = $users_collection->hasAnyObjectInCollection();

        // Recreate default User
        if (!$have_any_user || !$have_default_user) {
            //Remove all Users
            $users_collection = new AdminUserRepository;
            $users_collection->deleteObjectCollection();

            // Reset auto-increment
            $users_collection->alterTableResetAutoIncrement();

            // Create new default Developer
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 1, // Developer
                    'login'    => 'neTpyceB', // Name of vendor repo owner
                    'password' => $this->generateHash(Configuration::getInstance()->get('cms')['unique_key']), // Password is the same as unique key
                    'active'   => 1,
                ]
            );
            $user->save();

            // Create new default Manager
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 2, // Manager
                    'login'    => 'manager',
                    'password' => $this->generateHash(''), // Empty password
                    'active'   => 1,
                ]
            );
            $user->save();

            echo '<br>Default User "manager" and empty password is created.
			<br>
			Please log in and change password.
			<br>';
        }
    }
273589
def create_permission(self):
        """"""
        return Permission(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
20381
def reset
      self.user_agent         = DEFAULT_USER_AGENT
      self.environment        = DEFAULT_ENVIRONMENT
      self.api_version        = DEFAULT_API_VERSION
      self.server_url         = DEFAULT_SERVER_URL
      self.client_name        = DEFAULT_CLIENT_NAME
      self.client_key         = DEFAULT_CLIENT_KEY
      self.connection_options = DEFAULT_CONNECTION_OPTIONS
      self.middleware         = DEFAULT_MIDDLEWARE
      self.accept             = DEFAULT_ACCEPT
      self
    end
931812
protected function createSuperadmin()
    {
        $this->setCliMessage('Creating superadmin...');

        $user = array(
            'status' => 1,
            'name' => 'Superadmin',
            'store_id' => $this->context['store_id'],
            'email' => $this->data['user']['email'],
            'password' => $this->data['user']['password']
        );

        $user_id = $this->getUserModel()->add($user);

        $this->config->set('user_superadmin', $user_id);
        $this->setContext('user_id', $user_id);
    }
1081617
def setup(self):
        """"""
        if self.dry_run is not True:
            self.client = self._get_client()
            self._disable_access_key()
901583
public function buildDefaults()
    {
        $da = DatabaseAdmin::create();

        $renderer = null;
        if (!Director::is_cli()) {
            $renderer = DebugView::create();
            echo $renderer->renderHeader();
            echo $renderer->renderInfo("Defaults Builder", Director::absoluteBaseURL());
            echo "<div class=\"build\">";
        }

        $da->buildDefaults();

        if (!Director::is_cli()) {
            echo "</div>";
            echo $renderer->renderFooter();
        }
    }
1312991
def make_admin(user):
    '''
    
    '''
    tutor_group, owner_group = _get_user_groups()
    user.is_staff = True
    user.is_superuser = True
    user.save()
    owner_group.user_set.add(user)
    owner_group.save()
    tutor_group.user_set.add(user)
    tutor_group.save()
336320
public function runCreateAdmin()
    {
        $admin = $this->getContainer()->get('fos_user.user_manager')->findOneBy(
            [
                'username' => 'admin',
            ]
        );

        if (!$admin) {
            $this->runCommand(
                'fos:user:create',
                [
                    '--super-admin' => true,
                    'username' => 'admin',
                    'email' => 'admin@admin.com',
                    'password' => 'admin',
                ]
            );
        }
    }