Hi All,
we would need to create Users in $external to allow them to login via LDAP.
On command shell the following command:
db.getSiblingDB('$external').createUser({ user : 'username', roles: [ { role: 'dbOwner', db: 'databasename' } ] } )
Is working fine.
But as far as we are executing the same command via Java Driver we are getting exceptions.
Java Code:
DB db = mongoClient.getDB("$external");
String command = "db.getSiblingDB('$external').createUser({ user : '"+ userName +"', roles: [ { role: 'dbOwner', db: 'CMRepWs_'"+userName.toUpperCase()+"' } ] } )";
CommandResult result = db.command(command);
Result Message:
{ "serverUsed" : "lblasa1t.cm-cic.fr:27017" , "ok" : 0.0 , "errmsg" : "no such command: db.getSiblingDB('$external').createUser({ user : 'WANIYO', roles: [ { role: 'dbOwner', db: 'CMRepWs_WANIYO' } ] } )" , "code" : 59 , "bad cmd" : { "db.getSiblingDB('$external').createUser({ user : 'username', roles: [ { role: 'dbOwner', db: 'CMRepWs_username' } ] } )" : true}} We are running MongoDb Version 3.0.1 with Java Driver 2.13.1.
Would be great, if anybody has an idea, how we can create users in $external via the Java Driver.
Many thanks and best regards,
Jakob