[CSHARP-1548] Create User on database version 2.4.5 Created: 28/Jan/16  Updated: 05/Apr/19  Resolved: 28/Jan/16

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 2.2
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Kevin Versfeld Assignee: Unassigned
Resolution: Done Votes: 0
Labels: question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

How does one create a user on a 2.4.5 version of MongoDB, but from the C# driver version 2.2?
I am unfortunately temporarily stuck with a very old MongoDB server version (2.4.5), and am in the process of trying to upgrade both DB, and the C# driver. The driver documentation states compatibility with server 2.4, and so far it seems to be working. Where I am struggling now however is the creation of new users in a database.
I strongly suspect this will be quite a simple thing, I just can't for the life of me figure it out...



 Comments   
Comment by Craig Wilson [ 28/Jan/16 ]

Gotcha, makes sense. If the above doesn't work for you, let us know.

Craig

Comment by Kevin Versfeld [ 28/Jan/16 ]

Thanks!
So the reason is that we run a sort of multi-tenant setup for our application suite (SaaS product) where each client gets their own database. We "generate" on the fly (through another maintenance/admin app of our own) separate environments (including DB) that are specific to the customer, including a specific user account (with private password yada yada) which has access only to that DB. Soon, this process will also be available for clients who want to provision their own environments (so, even more automated than currently).

Comment by Craig Wilson [ 28/Jan/16 ]

Hi Kevin,

For server 2.4, you'll want to insert a users document into the system.users collection. You can see the form of it here: https://docs.mongodb.org/v2.4/reference/privilege-documents/#<database>.system.users. Basically, get a collection of type BsonDocument, create a BsonDocument using the above format, and call InsertOne.

Any particular reason you want to do this from the driver instead of the shell?

Craig

Generated at Wed Feb 07 21:39:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.