Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2853

Java MongoDB 3.6.1 Driver Authenticate Command

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Authentication
    • Labels:
      None

      I was attempting to perform a db.auth() or authenticate command through the driver 3.6.1 and got the following error.

       

      Error: com.mongodb.MongoCommandException: Command failed with error 2: 'Challenge-response authentication using getnonce and authenticate commands is disabled.' on server maas-gt-d4-u0038.nam.nsroot.net:37017. The full response is { "ok" : 0.0, "errmsg" : "Challenge-response authentication using getnonce and authenticate commands is disabled.", "code" : 2, "codeName" : "BadValue" }

       

      My Code

       

      mongodb://<user>:<pwd>@maas-gt-d4-u0038.nam.nsroot.net:37017/?ssl=true&authSource=admin&sslInvalidHostNameAllowed=true&authMechanism=SCRAM-SHA-1

       

             MongoDatabase mongoDB = mongoClient.getDatabase(databaseName);

             Document doc = mongoDB.runCommand(NativeAuthenticationHelper.getNonceCommand());

             BsonDocument auth = NativeAuthenticationHelper.getAuthCommand(<my user>, <my password>.toCharArray(), doc.getString("nonce"));

             Document res = mongoDB.runCommand(auth);

       

      I am able to connect to the MongoDB instance with that string from my local Tomcat application. SCRAM-SHA-1 is being used.

       

       

      Thanks & Regards,

      Preeti Gupta

            Assignee:
            Unassigned Unassigned
            Reporter:
            preeti3.gupta@citi.com Preeti Gupta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: