Get roles
Gets information about the specified fields
- Parameters
- Advanced call ?
Function GetRoles(Val Connection, Val RoleArray, Val Base = Undefined, Val GetPrivileges = False) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | --dbc | String, Arbitrary | ✔ | Connection or connection string |
| RoleArray | --roles | Arbitrary | ✔ | Role or list of roles |
| Base | --db | String | ✖ | Database name. Current database if not specified |
| GetPrivileges | --sprv | Boolean | ✖ | Adds a list of role privileges to the returned data |
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) |
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);
Role = New Structure("role,db", "newrole", Base);
Result = OPI_MongoDB.GetRoles(Connection, Role, Base, True);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint mongodb GetRoles \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--roles "{'role':'newrole','db':'admin'}" \
--db "admin" \
--sprv true
:: JSON data can also be passed as a path to a .json file
oint mongodb GetRoles ^
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" ^
--roles "{'role':'newrole','db':'admin'}" ^
--db "admin" ^
--sprv true
Result
{
"result": true,
"data": {
"roles": [
{
"_id": "admin.newrole",
"role": "newrole",
"db": "admin",
"privileges": [
{
"resource": {
"db": "admin",
"collection": "new_collection"
},
"actions": [
"find",
"insert",
"update"
]
}
],
"roles": [
{
"role": "read",
"db": "admin"
},
{
"role": "userAdmin",
"db": "admin"
}
],
"inheritedRoles": [
{
"role": "userAdmin",
"db": "admin"
},
{
"role": "read",
"db": "admin"
}
],
"inheritedPrivileges": [
{
"resource": {
"db": "admin",
"collection": "new_collection"
},
"actions": [
"find",
"insert",
"update"
]
},
{
"resource": {
"db": "admin",
"collection": ""
},
"actions": [
"changeCustomData",
"changePassword",
"changeStream",
"collStats",
"createRole",
"createUser",
"dbHash",
"dbStats",
"dropRole",
"dropUser",
"find",
"grantRole",
"killCursors",
"listCollections",
"listIndexes",
"listSearchIndexes",
"planCacheRead",
"revokeRole",
"setAuthenticationRestriction",
"viewRole",
"viewUser"
]
},
{
"resource": {
"db": "admin",
"collection": "system.js"
},
"actions": [
"changeStream",
"collStats",
"dbHash",
"dbStats",
"find",
"killCursors",
"listCollections",
"listIndexes",
"listSearchIndexes",
"planCacheRead"
]
}
],
"isBuiltin": false
}
],
"ok": 1
}
}