How to add / remove MongoDB User in SSIS

Introduction

In this blog post, you will learn how to call MongoDB Shell Commands from SSIS using the MongoDB ExecuteSQL task

Some use cases for calling MongoDB shell commands are listed here.

 

How to call MongoDB Shell Commands in SSIS

  1. Download and install SSIS PowerPack from here
  2. From the toolbox of the SSIS designer, drag  ZS MongoDB ExecuteSQL Task
  3. Click on New Connection (Next to the connection dropdown)
  4. Configure the MongoDB connection and click Test. Close UI by clicking OK
  5. Now, on the Task UI, configure it as below. Notice the “Examples” dropdown. That’s the best way to learn various commands.
  6. You can also use the “Insert Variables” option to make your command dynamic (Read value from SSIS variable)

    How to add/remove a MongoDB User in SSIS

Add MongoDB User

To add a MongoDB user using the MongoDB ExecuteSQL Task, use the following Script

 

Remove MongoDB User

To remove the MongoDB user using the MongoDB ExecuteSQL Task, use the following Script

 

List MongoDB Users from the Command Line

To list existing users for a specific database, perform the following steps.

  1. Open the command prompt and type mongo
  2. If needed, type userid/password (if not required, then do the next step)
  3. type use YourDBName
  4. Type db.getUsers()
How to list MongoDB dabase users using db.getUsers() on mongo command line

How to list MongoDB database users using db.getUsers() on the mongo command line

 

 

Posted in SSIS MongoDB ExecuteSQL and tagged , , .