Grant roles
Grants selected roles to a user
- Parameters
- Advanced call ?
Function GrantRoles(Val Connection, Val User, Val RoleArray, Val Base = Undefined, Val Parameters = Undefined) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | --dbc | String, Arbitrary | ✔ | Connection or connection string |
| User | --user | String | ✔ | Users name |
| RoleArray | --roles | Array Of Arbitrary | ✔ | Role or role array |
| Base | --db | String | ✖ | Database name. Current database if not specified |
| Parameters | --params | Structure Of KeyAndValue | ✖ | Additional deletion parameters |
Returns
Map Of KeyAndValue - Operation result
| Parameter | Description |
|---|---|
| addin_mode | Manual selection of external component connection mode (for 1C): Isolated, NotIsolated |
| dontwait | Creates a background job and returns its data (for 1C and OneScript only) |
tip
Role can be defined in one of the following formats:
Structure: { role: "name", db: "database" }
String: role name
1C:Enterprise/OneScript code example
Address = "127.0.0.1:1234";
Login = "bayselonarrend";
Password = "12we...";
Base = "admin";
ConnectionParams = New Structure("authSource", "admin");
ConnectionString = OPI_MongoDB.GenerateConnectionString(Address, , Login, Password, ConnectionParams);
Connection = OPI_MongoDB.CreateConnection(ConnectionString);
User = "bayselonarrend";
Role = New Structure("role,db", "newrole", Base);
Result = OPI_MongoDB.GrantRoles(Connection, User, Role, Base);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint mongodb GrantRoles \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--user "bayselonarrend" \
--roles "{'role':'newrole','db':'admin'}" \
--db "admin"
:: JSON data can also be passed as a path to a .json file
oint mongodb GrantRoles ^
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" ^
--user "bayselonarrend" ^
--roles "{'role':'newrole','db':'admin'}" ^
--db "admin"
Result
{
"result": true,
"data": {
"ok": 1
}
}