Skip to main content

Update user

Modifies existing user data

Function UpdateUser(Val Connection, Val Name, Val UserRoles = Undefined, Val Base = Undefined, Val Password = Undefined, Val Parameters = Undefined) Export

ParameterCLI optionTypeRequiredDescription
Connection--dbcString, ArbitraryConnection or connection string
Name--nameStringUsers name
UserRoles--rolesArray Of ArbitraryArray of roles as strings or structures specifying the DB
Base--dbStringDatabase name. Current database if not specified
Password--pwdStringUsers password
Parameters--paramsStructure Of KeyAndValueAdditional parameters
Returns

Map Of KeyAndValue - Operation result

tip

The passed roles completely replace the user's role list

Role can be defined in one of the following formats:
Structure: { role: "name", db: "database" }
String: role name


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);

RoleArray = New Array;
RoleArray.Add("readWrite");

UserName = "newuser";
UserPassword = "4321";

Result = OPI_MongoDB.UpdateUser(Connection, UserName, RoleArray, Base, UserPassword);
oint mongodb UpdateUser \
--dbc "mongodb://bayselonarrend:12we3456!2154@127.0.0.1:27017/?authSource=admin" \
--name "anotheruser" \
--roles "['readWrite']" \
--db "main" \
--pwd "4321"
Result
{
"result": true,
"data": {
"ok": 1
}
}