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
{
"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
}
}