dboo::odb::add_user
void add_user ( const __OSL_NS__::user_id& userid, 1)
const password& password,
const group_id& group,
const std::string& description = "");
void add_user ( const __OSL_NS__::user_id& userid, 2)
const password& password,
const std::vector<group_id>& groups,
const std::string& description = "");
add_user ( userid, password, group ) 1)
Creates a new user. A user with admin rights must be logged in to the server database for this operation to be successful. If the group does not exist it will be created.
- 1
Creates a user with one group
- 2
Creates a user with more than one group
Parameters
- userid
The new user id
- password
The nwe user’s password
- group
A group id which the user will belong to
- groups
A vector of group ids which the user will belong to
- description
A description for the user
Return value
(none)
Exceptions
Example
|
1#include <dboo/odb.h>
2#include <string>
3
4string host = "localhost";
5int port = 8822;
6string root_pwd = "admin";
7
8int main(int argc, char *argv) {
9 dboo::init();
10
11 auto db = dboo::odb{host, port, dboo::database_name::server, "root", root_pwd};
12
13 db.add_group("my-db", "Used for users of database my-db");
14 db.add_group("users", "Other uses");
15 db.add_user("me", "my password", {"users", "my-db"});
16}
|
1const dboo = require('dboo');
2
3
4const host = "localhost";
5const port = 8822;
6const root_pwd = "admin";
7
8dboo.init(); // Class declarations must come before init!
9
10const db = new dboo.odb();
11
12db.connect(host, port, dboo.server_root, "root", root_pwd);
13
14db.add_group("my-db", "Used for users of database my-db");
15db.add_group("users", "Used for normal users");
16db.add_user("me", "my password", ["users", "my-db"]);