[JAVA-1203] Java API should support db.createUser() Created: 07/May/14  Updated: 08/Nov/17  Resolved: 08/Nov/17

Status: Closed
Project: Java Driver
Component/s: API, Authentication
Affects Version/s: 2.12.1
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Rudi Wijaya Assignee: Unassigned
Resolution: Won't Fix Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

MongoDB 2.6.0 deprecates the db.addUser() and recommends the db.createUser() command.

However, the Java API deprecates the db.addUser() method and suggests using the low-level db.command() method:

    /**
     * Adds or updates a user for this database
     *
     * @param username the user name
     * @param passwd   the password
     * @return the result of executing this operation
     * @throws MongoException
     * @mongodb.driver.manual administration/security-access-control/  Access Control
     * @deprecated Use {@code DB.command} to call either the addUser or updateUser command
     */
    @Deprecated
    public WriteResult addUser( String username , char[] passwd ){
        return addUser(username, passwd, false);
    }

MongoDB Java Driver API should support db.createUser() as a replacement to db.addUser() (taking into account server version).

Related to SERVER-3301.



 Comments   
Comment by Jeffrey Yemin [ 08/Nov/17 ]

For the time being the drivers team has concluded that there is little benefit in providing API wrappers around user management commands, and recommend instead that applications construct commands dynamically and use MongoDatabase#runCommand.

Comment by Hendy Irawan [ 20/May/14 ]

jeff.yemin http://docs.mongodb.org/manual/reference/method/db.createUser/#db.createUser is the JavaScript API. The problem is DB.createUser() is not supported by the Java API, instead it suggests developers use server commands directly (which defeats the purpose of an API) :

 * @deprecated Use {@code DB.command} to call either the addUser or updateUser command

Comment by Jeffrey Yemin [ 07/May/14 ]

DB.addUser does call the createUser server command if it's talking to a 2.6 server. But it's true that DB.addUser() doesn't support the full range of options that the createUser server command supports. See http://docs.mongodb.org/manual/reference/method/db.createUser/#db.createUser.

Comment by Rudi Wijaya [ 07/May/14 ]

tag ceefour

Generated at Thu Feb 08 08:54:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.