Skip to content

USER BAN

ElbyFross edited this page Jan 20, 2020 · 3 revisions

Remarks

An IQueryHandler that creates a new user.

  • Located at the AuthorityController.Queries namespace into the USER_NEW class.
  • Sets a temporaly or permanent ban for some user.
  • You define which rights will be bannes.
  • The rank of requesting user must be higher than the rank of user that will banned.

By default requires following rights from a requester:

  • banhammer
  • >rank=2 - at least moderator

Required rights could be modified via the Config by change the QUERY_UserBan_RIGHTS field's value.

Query's parts

The query must contains all the listed parameters.

Keyword Description
user id or login of the user that will be banned.
ban A BanInformationinstance that describes the ban serialized to binary format.
token A guest token provided to a client app.
guid An unique GUID of the query.

Query results

In case if banned success the returns success message using the UniformServer.BaseServer.SendAnswerViaPP.

Error Message
User not found "ERROR 404: User not found"
Invalid SQL query "ERROR SQL SERVER: DATAILS", where DATAILS is an asnwer of the SQL server.
Target user has undefined rank "ERROR 401: User rank not defined"
Not enough rights "ERROR 401: Unauthorized"

Example

The following example demostrates executing of the USER BAN query. In that example will permanently banned a logon right for some user.

C#

// Building ban information.
BanInformation banInformation = BanInformation.Permanent;
banInformation.blockedRights = new string[] { "logon" };

// Building query.
Query query = new Query(
    new QueryPart("token", TOKEN),
    new QueryPart("guid", "banUserExample"),
    new QueryPart("user", "USER_ID_FOR_BAN"),
    new QueryPart("ban", banInformation));

// Start reciving clent line.
UniformClient.BaseClient.EnqueueDuplexQueryViaPP(
    // Request connection to localhost server via main pipe.
    SERVER_IP, PIPE_NAME,
    query,
    // Handler that will recives a server's answer.
    (PipesProvider.Client.TransmissionLine line, Query answer) =>
    {
        string answerS = answer.First.PropertyValueString;
        if(answerS.StartsWith("error", StringComparison.OrdinalIgnoreCase))
        {
            // An error occured.
        }
    });
  • Where TOKEN is an unique session token provided to an app\user by the SessionProvider server or by some custom equivalent.
  • Where the SERVER_IP is an ip adress or the name of the computer into a local network.
  • Where the PIPE_NAME is a name of the named pipe started on the server.
  • Where the USER_ID_FOR_BAN is an id or login of a User that will banned.

Related links

Projects

Related pages