Get users
Gets data of one or more users
- Parameters
- Advanced call ?
Function GetUsers(Val Connection, Val Users, Val Base = Undefined, Val GetPassword = False, Val GetPrivileges = False) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | --dbc | String, Arbitrary | ✔ | Connection or connection string |
| Users | --usrs | Arbitrary | ✔ | Username, structure, or array of user structures |
| Base | --db | String | ✖ | Database name. Current database if not specified |
| GetPassword | --spwd | Boolean | ✖ | Adds user password hash to the returned data |
| GetPrivileges | --sprv | Boolean | ✖ | Adds a list of user 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) |
tip
The user can be specified in one of the following formats:
String: name of user
Structure: { user: <name>, db: <database> }
Array: [ { user: <name>, db: <database> }, { user: <name>, db: <database> }, ... ]
1C:Enterprise/OneScript code example
Address = "127.0.0.1:1234";
Login = "bayselonarrend";
Password = "12we...";
Base = "main";
ConnectionParams = New Structure("authSource", "admin");
ConnectionString = OPI_MongoDB.GenerateConnectionString(Address, , Login, Password, ConnectionParams);
Connection = OPI_MongoDB.CreateConnection(ConnectionString);
UserName = "newuser";
Result = OPI_MongoDB.GetUsers(Connection, UserName, Base);
ArrayOfUsers = New Array;
ArrayOfUsers.Add(New Structure("user,db", "bayselonarrend", "admin"));
ArrayOfUsers.Add(New Structure("user,db", "newuser" , "main"));
Result = OPI_MongoDB.GetUsers(Connection, ArrayOfUsers, Base, True, True);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint mongodb GetUsers \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--usrs "[{'user':'bayselonarrend','db':'admin'},{'user':'newuser','db':'main'}]" \
--db "main" \
--spwd true \
--sprv true
:: JSON data can also be passed as a path to a .json file
oint mongodb GetUsers ^
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" ^
--usrs "[{'user':'bayselonarrend','db':'admin'},{'user':'newuser','db':'main'}]" ^
--db "main" ^
--spwd true ^
--sprv true
Result
{
"result": true,
"data": {
"users": [
{
"_id": "admin.bayselonarrend",
"userId": {
"__B64_BINARY__": "EjWtfR/yQgGol18zZoi5HA=="
},
"user": "bayselonarrend",
"db": "admin",
"mechanisms": [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
],
"credentials": {
"SCRAM-SHA-1": {
"iterationCount": 10000,
"salt": "Qav4apyB+3UkB53eZtIiEA==",
"storedKey": "***",
"serverKey": "***"
},
"SCRAM-SHA-256": {
"iterationCount": 15000,
"salt": "nLO0xnlSs9iMSpmKP3tEv0hCiwk7helxkaomuQ==",
"storedKey": "***",
"serverKey": "***"
}
},
"roles": [
{
"role": "root",
"db": "admin"
}
],
"inheritedRoles": [
{
"role": "root",
"db": "admin"
}
],
"inheritedPrivileges": [
{
"resource": {
"cluster": true
},
"actions": [
"addShard",
"allCollectionStats",
"appendOplogNote",
"applicationMessage",
"auditConfigure",
"authSchemaUpgrade",
"bypassWriteBlockingMode",
"cleanupOrphaned",
"connPoolStats",
"connPoolSync",
"dropConnections",
"flushRouterConfig",
"forceUUID",
"fsync",
"getClusterParameter",
"getDefaultRWConcern",
"getCmdLineOpts",
"getLog",
"getParameter",
"getShardMap",
"hostInfo",
"inprog",
"invalidateUserCache",
"killAnyCursor",
"killAnySession",
"killop",
"listDatabases",
"listSessions",
"listShards",
"logRotate",
"netstat",
"oidReset",
"operationMetrics",
"queryStatsRead",
"queryStatsReadTransformed",
"removeShard",
"replSetConfigure",
"replSetGetConfig",
"replSetGetStatus",
"replSetResizeOplog",
"replSetStateChange",
"resync",
"rotateCertificates",
"runTenantMigration",
"serverStatus",
"setClusterParameter",
"setDefaultRWConcern",
"setFeatureCompatibilityVersion",
"setParameter",
"setUserWriteBlockMode",
"shardedDataDistribution",
"shardingState",
"shutdown",
"top",
"touch",
"trafficRecord",
"unlock",
"useTenant",
"useUUID",
"viewUser",
"applyOps"
]
},
{
"resource": {
"db": "",
"collection": ""
},
"actions": [
"bypassDocumentValidation",
"changeCustomData",
"changePassword",
"changeStream",
"clearJumboFlag",
"collMod",
"collStats",
"compact",
"compactStructuredEncryptionData",
"convertToCapped",
"createCollection",
"createIndex",
"createRole",
"createSearchIndexes",
"createUser",
"dbHash",
"dbStats",
"dropCollection",
"dropDatabase",
"dropIndex",
"dropSearchIndex",
"dropRole",
"dropUser",
"enableProfiler",
"enableSharding",
"find",
"getDatabaseVersion",
"getShardVersion",
"grantRole",
"indexStats",
"insert",
"killCursors",
"listCachedAndActiveUsers",
"listCollections",
...