How to add, remove, modify users using SQL?


With Firebird 2.5 and above, you can use CREATE, ALTER and DROP USER commands.

CREATE USER fadmin PASSWORD 'fbfaq12';
ALTER USER fadmin FIRSTNAME 'Firebird' LASTNAME 'Admin';
ALTER USER fadmin PASSWORD 'newpass123';
DROP USER fadmin;

To do this, you have to connect to a database (for example, employee.fdb). The privileges depend on the user type. Only SYSDBA can
CREATE and DROP users. Ordinary users can ALTER his own password and first, middle and last name. If you wish to allow some user other than SYSDBA to administer other users, you should grant him the RDB$ADMIN role in security database. Since no user can connect to security database directly, you need to connect to any regular database and issue a special GRANT ADMIN ROLE command. For example, if you wish user MIKE to be able to administer other users, connect to a database as SYSDBA and then run:

ALTER USER MIKE GRANT ADMIN ROLE;

Note that MIKE must supply the role RDB$ADMIN when connecting to a database to get the privileges. Most administration tools have the role option on login screen (alongside username and password), with ISQL you can use -role or -r2 options. For more details, please refer to Firebird 2.5 release notes under Administrative Features section.

With earlier Firebird versions you need to use service API. Access to it is provided by most connectivity libraries (except ODBC). Please do the same search on FAQ without SQL keyword to get the relevant info.

With earlier version of Firebird, you can also use open source rFunc UDF library which has functions for user manipulation:

http://rfunc.sourceforge.net


Do you find this FAQ incorrect or incomplete? Please e-mail us what needs to be changed. To ensure quality, each change is checked by our editors (and often tested on live Firebird databases), before it enters the main FAQ database. If you desire so, the changes will be credited to your name. To learn more, visit our add content page.

If you are a commercial tool maker and your tool features a great way to handle the issue written about in this FAQ, please check out our advertisement page.



All contents are copyright © 2007-2014 FirebirdFAQ.org unless otherwise stated in the text.


Links   Firebird   News   FlameRobin   Home Inventory powered by FB  
Add content   Advertise   About  

Categories
 Newbies
 SQL
 Installation and setup
 Backup and restore
 Performance
 Security
 Connectivity and API
 HOWTOs
 Errors and error codes
 Miscellaneous