Setting up authorization in Windows Server
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:
If an error is received after executing the connect command:
MongoDB administration utilities are not located in the $PATH environment variable, you must search for the mongosh.exe utility to connect:
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:
Switch to database — admin:
Create a user by changing the Login (user) and Password (pwd) of the user:
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:
You need to edit the MongoDB config file to enable authorisation, run the following commands in the shell to get the location:
Edit the resulting configuration file by adding a line:
Save the changes and restart the MongoDB service in PowerShell:
To test, connect to the shell with authorisation:
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:
Save the changes and refresh the Passwork web interface page to test the connection with MongoDB authorisation.