Database
...
MongoDB
Examples of authorization sett...

Setting up authorization in Windows Server

12min

Connecting and creating a user in MongoDB

Connection to shell

Open PowerShell as — "Administrator":

  • Right-click on the "Start" icon in the lower left corner of the screen;
  • Select "Windows PowerShell (Administrator)" from the context menu.

Connect to the MongoDB shell:

PowerShell


Shell connection error

If an error is received after executing the connect command:

PowerShell


MongoDB administration utilities are not located in the $PATH environment variable, you must search for the mongosh.exe utility to connect:

PowerShell


If MongoDB and the administration utilities were installed on a non-standard drive, you need to change the search path in the -Path parameter.

Once executed, the current working directory will be changed to the one where the utility is located — mongosh.exe

Connect to the MongoDB shell:

PowerShell


Creating a user

Switch to database — admin:

Shell


Create a user by changing the Login (user) and Password (pwd) of the user:

Shell


In MongoDB, you cannot use the characters — .,@,$,:,%,",',/,\,| in the username and password, as this can cause failures and connection of the application server to MongoDB.

If a MongoDB replica set is used, you must add the cluster manager role to the user:

Shell


Enabling authorisation and connecting Passwork

Enabling authorisation in MongoDB

You need to edit the MongoDB config file to enable authorisation, run the following commands in the shell to get the location:

Shell


Edit the resulting configuration file by adding a line:

Shell


Save the changes and restart the MongoDB service in PowerShell:

PowerShell


To test, connect to the shell with authorisation:

PowerShell


Setting up and connecting Passwork with authorization

You need to edit the Passwork configuration file — C:\inetpub\wwwroot\passwork\app\config\config.ini section [mongo] by specifying the login (user) and password (pwd) of the created user:

Shell


Save the changes and refresh the Passwork web interface page to test the connection with MongoDB authorisation.