const classafMongo::User

sys::Obj
  afMongo::User

Represents a MongoDB user.

To enable authentication, ensure MongoDB was 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

Source

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

Source

This drop(Bool checked := true)

exists

Source

Bool exists()

Returns true if this user exists.

grantRoles

Source

This grantRoles(Str[] roles, [Str:Obj?]? writeConcern := null)

info

Source

Str:Obj? info()

make

Source

new make(ConnectionManager conMgr, Str dbName, Str userName, |This? f := null)

Creates a User with the given details.

name

Source

const Str name

The name of this user.

revokeRoles

Source

This revokeRoles(Str[] roles, [Str:Obj?]? writeConcern := null)

roles

Source

Str[] roles()

Returns all roles held by this user.

writeConcern

Source

const Str:Obj? writeConcern := MongoConstants.defaultWriteConcern

The write concern to use for user writes.