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 MongoDB ExecuteSQL task

Some of the use cases of 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 toolbox of SSIS designer drag  ZS MongoDB ExecuteSQL Task
  3. Click on New Connection (Next to connection dropdown)
  4. Configure MongoDB connection and click Test. Close UI by clicking OK
  5. Now on the Task UI configure it as below. Notice “Examples” dropdown. that’s best way to learn various commands.
  6. You can also use “Insert Variables” option to make your command dynamic (Read value from SSIS variable)
Calling MongoDB Shell command in SSIS (Example- Add/Remove Users)

Calling MongoDB Shell command in SSIS (Example- Add/Remove Users)

 

Add MongoDB User

To Add MongoDB user using MongoDB ExecuteSQL Task use following Script

 

Remove MongoDB User

To Remove MongoDB user using MongoDB ExecuteSQL Task use following Script

 

List MongoDB Users from Command Line

To list existing users for specific database perform following steps.

  1. Open command prompt and type mongo
  2. If needed type userid/password (if not needed then do 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 dabase users using db.getUsers() on mongo command line

 

 

Posted in SSIS MongoDB ExecuteSQL and tagged , , .