FirebirdSQL logo
 User AuthenticationSQL Privileges 

This section describes the SQL statements for creating, altering and dropping Firebird user accounts.These statements can be executed by the following users:

  • SYSDBA

  • Any user with the RDB$ADMIN role in the security database

  • When the AUTO ADMIN MAPPING flag is enabled in the security database ({secdb} or the security database configured for the current database in the databases.conf), any Windows Administrator — assuming Win_Sspi was used to connect without specifying roles.

  • Any user with the system privilege USER_MANAGEMENT in the security database

    Note

    For a Windows Administrator, AUTO ADMIN MAPPING enabled only in a regular database is not sufficient to permit management of other users.For instructions to enable it in the security database, see [fblangref50-security-autoadminmapping02].

Non-privileged users can use only the ALTER USER statement, and then only to modify some data of their own account.

CREATE USER

Creates a Firebird user account

Available in

DSQL

Syntax
CREATE USER username
  <user_option> [<user_option> ...]
  [TAGS (<user_var> [, <user_var> ...]]

<user_option> ::=
    PASSWORD 'password'
  | FIRSTNAME 'firstname'
  | MIDDLENAME 'middlename'
  | LASTNAME 'lastname'
  | {GRANT | REVOKE} ADMIN ROLE
  | {ACTIVE | INACTIVE}
  | USING PLUGIN plugin_name

<user_var> ::=
    tag_name = 'tag_value'
  | DROP tag_name
Table 1. CREATE USER Statement Parameters
Parameter Description

username

Username.The maximum length is 63 characters, following the rules for Firebird identifiers.

password

User password.Valid or effective password length depends on the user manager plugin.Case-sensitive.

firstname

Optional: User’s first name.Maximum length 32 characters

middlename

Optional: User’s middle name.Maximum length 32 characters

lastname

Optional: User’s last name.Maximum length 32 characters.

plugin_name

Name of the user manager plugin.

tag_name

Name of a custom attribute.The maximum length is 63 characters, following the rules for Firebird regular identifiers.

tag_value

Value of the custom attribute.The maximum length is 255 characters.

If the user already exist in the Firebird security database for the specified user manager plugin, an error is raised.It is possible to create multiple users with the same name: one per user manager plugin.

The username argument must follow the rules for Firebird regular identifiers: see Identifiers in the Structure chapter.Usernames are case-sensitive when double-quoted (in other words, they follow the same rules as other delimited identifiers).

Important

Usernames follow the general rules and syntax of identifiers.Thus, a user named "Alex" is distinct from a user named "ALEX"

CREATE USER ALEX PASSWORD 'bz23ds';

- this user is the same as the first one
CREATE USER Alex PASSWORD 'bz23ds';

- this user is the same as the first one
CREATE USER "ALEX" PASSWORD 'bz23ds';

- and this is a different user
CREATE USER "Alex" PASSWORD 'bz23ds';

The PASSWORD clause specifies the user’s password, and is required.The valid or effective password length depends on the user manager plugin, see also [fblangref50-security-auth].

The optional FIRSTNAME, MIDDLENAME and LASTNAME clauses can be used to specify additional user properties, such as the person’s first name, middle name and last name, respectively.These are VARCHAR(32) fields and can be used to store anything you prefer.

If the GRANT ADMIN ROLE clause is specified, the new user account is created with the privileges of the RDB$ADMIN role in the security database ({secdb} or database-specific).It allows the new user to manage user accounts from any regular database they log into, but it does not grant the user any special privileges on objects in those databases.

The REVOKE ADMIN ROLE clause is syntactically valid in a CREATE USER statement, but has no effect.It is not possible to specify GRANT ADMIN ROLE and REVOKE ADMIN ROLE in one statement.

The ACTIVE clause specifies the user is active and can log in, this is the default.

The INACTIVE clause specifies the user is inactive and cannot log in.It is not possible to specify ACTIVE and INACTIVE in one statement.The ACTIVE/INACTIVE option is not supported by the Legacy_UserManager and will be ignored.

The USING PLUGIN clause explicitly specifies the user manager plugin to use for creating the user.Only plugins listed in the UserManager configuration for this database (firebird.conf, or overridden in databases.conf) are valid.The default user manager (first in the UserManager configuration) is applied when this clause is not specified.

Important

Users of the same name created using different user manager plugins are different objects.Therefore, the user created with one user manager plugin can only be altered or dropped by that same plugin.

From the perspective of ownership, and privileges and roles granted in a database, different user objects with the same name are considered one and the same user.

The TAGS clause can be used to specify additional user attributes.Custom attributes are not supported (silently ignored) by the Legacy_UserManager.Custom attributes names follow the rules of Firebird identifiers, but are handled case-insensitive (for example, specifying both "A BC" and "a bc" will raise an error).The value of a custom attribute can be a string of maximum 255 characters.The DROP tag_name option is syntactically valid in CREATE USER, but behaves as if the property is not specified.

Warning

Users can view and alter their own custom attributes.Do not use this for sensitive or security related information.

Note

CREATE/ALTER/DROP USER are DDL statements, and only take effect at commit.Remember to COMMIT your work.In isql, the command SET AUTO ON will enable autocommit on DDL statements.In third-party tools and other user applications, this may not be the case.