const classafMongo::User
sys::Obj afMongo::User
Represents a MongoDB user.
To enable authentication, ensure MongoDB is started in secure mode:
C:\> mongod --auth
If you don't then all users have access to all databases.
Users are assigned roles. Built-in roles for all databases are:
- read
- readWrite
- dbAdmin
- dbOwner
- userAdmin
Built in roles for the admin database are:
- readWriteAnyDatabase
- userAdminAnyDatabase
- dbAdminAnyDatabase
To create a superuser, or root user, grant her ALL of the above admin database roles. (It's always handy to have one!)
Note in this API all user roles are bound to the containing database.
- create
This create(Str password, Str[] roles, [Str:Obj?]? customData := null, [Str:Obj?]? writeConcern := null)
Creates the user with the given credentials.
@see http://docs.mongodb.org/manual/reference/command/createUser/
- drop
This drop(Bool checked := true)
Drops this user.
@see http://docs.mongodb.org/manual/reference/command/dropUser/
- exists
Bool exists()
Returns
true
if this user exists.- grantRoles
This grantRoles(Str[] roles, [Str:Obj?]? writeConcern := null)
Grants roles to the user.
@see http://docs.mongodb.org/manual/reference/command/grantRolesToUser/
- info
Returns info on the user.
@see http://docs.mongodb.org/manual/reference/command/usersInfo/
- make
new make(ConnectionManager conMgr, Str dbName, Str userName, |This? f := null)
Creates a
User
with the given details.- name
const Str name
The name of this user.
- revokeRoles
This revokeRoles(Str[] roles, [Str:Obj?]? writeConcern := null)
Revokes roles from the user.
@see http://docs.mongodb.org/manual/reference/command/revokeRolesFromUser/
- roles
Str[] roles()
Returns all roles held by this user.