---
sidebar_position: 3
description: Get roles and other functions to work with MongoDB in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, MongoDB]
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Get roles
 Gets information about the specified fields



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

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Connection | --dbc | String, Arbitrary | &#x2714; | Connection or connection string |
  | RoleArray | --roles | Arbitrary | &#x2714; | Role or list of roles |
  | Base | --db | String | &#x2716; | Database name. Current database if not specified |
  | GetPrivileges | --sprv | Boolean | &#x2716; | Adds a list of role privileges to the returned data |

  
  Returns:  Map Of KeyAndValue - Operation result



```bsl title="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);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # 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
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: 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
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "result": true,
 "data": {
  "roles": [
   {
    "_id": "admin.newrole",
    "role": "newrole",
    "db": "admin",
    "privileges": [
     {
      "resource": {
       "db": "admin",
       "collection": "new_collection"
      },
      "actions": [
       "***",
       "***",
       "***"
      ]
     }
    ],
    "roles": [
     {
      "role": "read",
      "db": "admin"
     },
     {
      "role": "userAdmin",
      "db": "admin"
     }
    ],
    "inheritedRoles": [
     {
      "role": "read",
      "db": "admin"
     },
     {
      "role": "userAdmin",
      "db": "admin"
     }
    ],
    "inheritedPrivileges": [
     {
      "resource": {
       "db": "admin",
       "collection": "new_collection"
      },
      "actions": [
       "***",
       "***",
       "***"
      ]
     },
     {
      "resource": {
       "db": "admin",
       "collection": ""
      },
      "actions": [
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***"
      ]
     },
     {
      "resource": {
       "db": "admin",
       "collection": "system.js"
      },
      "actions": [
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***",
       "***"
      ]
     }
    ],
    "isBuiltin": false
   }
  ],
  "ok": 1
 }
}
```
