Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1060

Authentication is not done for DBCollection.createIndex()

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.9, 1.9.1, 1.9.2
    • Component/s: Connectivity
    • Labels:
    • Environment:
      Windows 7

      I have enabled auth on MongoDB and created an admin user using:

      db.createUser(
        {  
          user: "admin",
          pwd: "***", 
          roles:
          [  
            { role: "root", db: "admin"  }, 
            { role: "dbAdminAnyDatabase", db: "admin" },
            { role: "readWriteAnyDatabase", db: "admin" },
            { role: "readWrite", db: "deadline7db" },  
            { role: "dbOwner", db: "deadline7db" },  
            { role: "dbAdmin", db: "deadline7db" },  
            { role: "readWrite", db: "admin" },  
            { role: "dbOwner", db: "deadline7db_Jobs" },  
            { role: "dbOwner", db: "deadline7db_Tasks" },  
            { role: "dbAdmin", db: "deadline7db_Jobs" },  
          ]  
        }  
      )  
      

      When I am trying to connect my application to this database using this user and password, it is connecting fine but throwing an error when trying to create index on deadline7db_Jobs.Job collection.

      Below is the error:

      Command 'createIndexes' failed: not authorized on deadline7db_Jobs to execute command { createIndexes: "Jobs", indexes: [ { ns: "deadline7db_Jobs.Jobs", name: "Stat_1_Props.Pool_1_Props.Grp_1_IsSub_1", key: { Stat: 1, Props.Pool: 1, Props.Grp: 1, IsSub: 1 } } ] } (response: { "ok" : 0.0, "errmsg" : "not authorized on deadline7db_Jobs to execute command { createIndexes: \"Jobs\", indexes: [ { ns: \"deadline7db_Jobs.Jobs\", name: \"Stat_1_Props.Pool_1_Props.Grp_1_IsSub_1\", key: { Stat: 1, Props.Pool: 1, Props.Grp: 1, IsSub: 1 } } ] }", "code" : 13 }).
      

      I can create index from Mongo shell.

            Assignee:
            Unassigned Unassigned
            Reporter:
            vibhu.kasrija Vibhu Kasrija
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: