Set vswitch to grant user.
540896
def grant_user_to_vswitch(self, vswitch_name, userid):
        """"""
        smt_userid = zvmutils.get_smt_userid()
        requestData = ' '.join((
            'SMAPI %s API Virtual_Network_Vswitch_Set_Extended' % smt_userid,
            "--operands",
            "-k switch_name=%s" % vswitch_name,
            "-k grant_userid=%s" % userid,
            "-k persist=YES"))

        try:
            self._request(requestData)
        except exception.SDKSMTRequestFailed as err:
            LOG.error("Failed to grant user %s to vswitch %s, error: %s"
                      % (userid, vswitch_name, err.format_message()))
            self._set_vswitch_exception(err, vswitch_name)
927377
def grant_usage_privileges(cls, cur, schema_name, roles):
        
        cur.execute('GRANT USAGE ON SCHEMA {0} TO {1};'
                    'GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA {0} TO {1};'
                    .format(schema_name, roles))
110718
def set_alias(cls, domain, login, aliases):
        """"""
        return cls.call('domain.mailbox.alias.set', domain, login, aliases)
1081617
def setup(self):
        """"""
        if self.dry_run is not True:
            self.client = self._get_client()
            self._disable_access_key()
702841
def add_domain_user_role(request, user, role, domain):
    """"""
    manager = keystoneclient(request, admin=True).roles
    return manager.grant(role, user=user, domain=domain)
1066534
public function forceSwitch($dbHost, $dbName, $dbUser, $dbPassword, array $dbOptions = array())
    {
        if ($this->getSession()->has(self::SESSION_CONNECTION_KEY)) {
            $current = $this->getSession()->get(self::SESSION_CONNECTION_KEY);
            if ($current[self::PARAM_HOST] === $dbHost && $current[self::PARAM_DATABASE] === $dbName) {
                return false;
            }
        }

        $this->getSession()->set(self::SESSION_CONNECTION_KEY, array(
            self::PARAM_DRIVER_OPTIONS => $dbOptions,
            self::PARAM_HOST           => $dbHost,
            self::PARAM_DATABASE       => $dbName,
            self::PARAM_USER           => $dbUser,
            self::PARAM_PASSWORD       => $dbPassword,
        ));

        if ($this->isConnected()) {
            $this->close();
        }

        return true;
    }
522498
def comply(self, path):
        """"""
        utils.ensure_permissions(path, self.user.pw_name, self.group.gr_name,
                                 self.mode)
366156
def DropPrivileges():
  """"""
  if config.CONFIG["Server.username"]:
    try:
      os.setuid(pwd.getpwnam(config.CONFIG["Server.username"]).pw_uid)
    except (KeyError, OSError):
      logging.exception("Unable to switch to user %s",
                        config.CONFIG["Server.username"])
      raise
568305
def power_on(env, identifier):
    """"""

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    env.client['Virtual_Guest'].powerOn(id=vs_id)
551162
def cli(env, identifier, enable, permission, from_user):
    """"""
    mgr = SoftLayer.UserManager(env.client)
    user_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'username')
    result = False
    if from_user:
        from_user_id = helpers.resolve_id(mgr.resolve_ids, from_user, 'username')
        result = mgr.permissions_from_user(user_id, from_user_id)
    elif enable:
        result = mgr.add_permissions(user_id, permission)
    else:
        result = mgr.remove_permissions(user_id, permission)

    if result:
        click.secho("Permissions updated successfully: %s" % ", ".join(permission), fg='green')
    else:
        click.secho("Failed to update permissions: %s" % ", ".join(permission), fg='red')
44904
def registergrant(source=None, setspec=None):
    """"""
    with open(source, 'r') as fp:
        data = json.load(fp)
    register_grant(data)
91815
protected void setPermissionStatus(PermissionStatus ps) {
    setUser(ps.getUserName());
    setGroup(ps.getGroupName());
    setPermission(ps.getPermission());
  }
209368
def require_user(self, *users, user=None):
        """"""

        # accept old-style single user keyword-argument as well
        if user:
            users = (*users, user)

        def _require_auth(view_func):
            @wraps(view_func)
            def wrapper(*args, **kwargs):
                """ Effective wrapper """
                username, out_token = self.authenticate()
                if username and out_token:
                    b64_token = base64.b64encode(out_token).decode('utf-8')
                    auth_data = 'Negotiate {0}'.format(b64_token)
                    if not users or username in users:
                        response = make_response(view_func(*args,
                                                           username=username,
                                                           **kwargs))
                    else:
                        response = Response(status=403)
                    response.headers['WWW-Authenticate'] = auth_data
                    return response
                return Response(
                    status=401,
                    headers={'WWW-Authenticate': 'Negotiate'},
                )

            return wrapper
        return _require_auth
1013330
def su(user)
      if defined?(Etc)
        pw = Etc.getpwnam(user)
        Process::initgroups(user, pw.gid)
        Process::Sys::setgid(pw.gid)
        Process::Sys::setuid(pw.uid)
      else
        warn("WEBrick::Utils::su doesn't work on this platform")
      end
    end
962321
function sessionValueSwitch(req, queryParam, sessionKey) {
    if(req.query[queryParam]) {
        if(req.user && req.user.role !== 'guest' && typeify(req.query[queryParam]) === true) {
            req.session[sessionKey] = true;
        } else if(typeify(req.query[queryParam]) === false) {
            req.session[sessionKey] = false;
        }
    }
    return req.session ? req.session[sessionKey] : false;
}
85867
def guest_start(self, userid):
        """""""
        LOG.info("Begin to power on vm %s", userid)
        self._smtclient.guest_start(userid)
        LOG.info("Complete power on vm %s", userid)
787791
def on_connect(client):
    """"""
    client.nick(client.user.nick)
    client.userinfo(client.user.username, client.user.realname)