Skip to main content

Get roles

Gets information about the specified fields

Function GetRoles(Val Connection, Val RoleArray, Val Base = Undefined, Val GetPrivileges = False) Export

ParameterCLI optionTypeRequiredDescription
Connection--dbcString, ArbitraryConnection or connection string
RoleArray--rolesArbitraryRole or list of roles
Base--dbStringDatabase name. Current database if not specified
GetPrivileges--sprvBooleanAdds a list of role privileges to the returned data
Returns

Map Of KeyAndValue - Operation result

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);
# 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
{
"data": {
"ok": 1,
"roles": [
{
"_id": "admin.newrole",
"db": "admin",
"inheritedPrivileges": [
{
"actions": [
"find",
"insert",
"update"
],
"resource": {
"collection": "new_collection",
"db": "admin"
}
},
{
"actions": [
"changeCustomData",
"changePassword",
"changeStream",
"collStats",
"createRole",
"createUser",
"dbHash",
"dbStats",
"dropRole",
"dropUser",
"find",
"grantRole",
"killCursors",
"listCollections",
"listIndexes",
"listSearchIndexes",
"planCacheRead",
"revokeRole",
"setAuthenticationRestriction",
"viewRole",
"viewUser"
],
"resource": {
"collection": "",
"db": "admin"
}
},
{
"actions": [
"changeStream",
"collStats",
"dbHash",
"dbStats",
"find",
"killCursors",
"listCollections",
"listIndexes",
"listSearchIndexes",
"planCacheRead"
],
"resource": {
"collection": "system.js",
"db": "admin"
}
}
],
"inheritedRoles": [
{
"db": "admin",
"role": "read"
},
{
"db": "admin",
"role": "userAdmin"
}
],
"isBuiltin": false,
"privileges": [
{
"actions": [
"find",
"insert",
"update"
],
"resource": {
"collection": "new_collection",
"db": "admin"
}
}
],
"role": "newrole",
"roles": [
{
"db": "admin",
"role": "read"
},
{
"db": "admin",
"role": "userAdmin"
}
]
}
]
},
"result": true
}