title: Define users and roles in MongoDB
body: <p>I'm trying to define a user in MongoDB which able to read the all collection within the DB but able to insert data to only two collections: Logs and Metrics.</p>
  
  <p>I used the next commands to set it:
  Create a role:</p>
  
  <pre><code>use Emerald
  db.runCommand({ createRole: "ApiReaderRole",
    privileges: [
      { resource: { db: "Emerald", collection: "Metrics" }, actions:  [ "insert" ] },
      { resource: { db: "Emerald", collection: "Logs" }, actions:  [ "insert" ] }
    ],
    roles: [
      { role: "read", db:"Emerald" }
    ],
    writeConcern: { w: "majority" , wtimeout: 5000 }
  })
  </code></pre>
  
  <p>Create a user:</p>
  
  <pre><code>use Emerald
  
  db.createUser({
      "user": "EmeraldAPIreader",
      "pwd": "emrldApi+",
      "roles": [
          {
              role: "ApiReaderRole",
              db: "Emerald"
          },
          {
              role: "read",
              db: "Emerald"
          }
      ]
  },
  {
      w: "majority",
      wtimeout: 5000
  })
  </code></pre>
  
  <p>I add the required credentials to the connection string and when I'm trying to insert (through C# code) a data to collections which I defined as read only, it succeeds (I'm expecting to get an unauthorized exception).
  What am I doing wrong?</p>