MongoDB
Discover system accounts and their permissions
JDBC Connection String
jdbc:mongodb://mongodb.example.com:27017/database
Validate Credentials
db.runCommand({
connectionStatus: 1,
showPrivileges: true
}).authInfo.authenticatedUserRoles.map(role => ({
integration_specific_id: role.role,
username: role.role,
email: role.role,
user_status: 'ACTIVE',
account_type: role.db === 'admin' ? 'SERVICE' : 'USER'
}))[0];
List Accounts
db.getSiblingDB('admin').system.users.find({}, {
user: 1,
roles: 1
}).map(user => ({
integration_specific_id: user.user,
username: user.user,
email: user.user,
user_status: 'ACTIVE',
account_type: user.roles.some(r => r.db === 'admin') ? 'SERVICE' : 'USER'
}));
List Entitlements
db.getSiblingDB('admin').system.roles.find({}, {
role: 1,
db: 1
}).map(role => ({
integration_specific_id: 'ROLE_' + role.role,
integration_specific_resource_id: role.db,
entitlement_type: 'ROLE',
label: 'Role - ' + role.role,
is_assignable: true
}));
Find Entitlement Associations
db.getSiblingDB('admin').system.users.find({}, {
user: 1,
roles: 1
}).map(user =>
user.roles.map(role => ({
account_id: user.user,
integration_specific_entitlement_id: 'ROLE_' + role.role,
integration_specific_resource_id: role.db
}))
).flat();
List Resources
[{
integration_specific_id: db.getName(),
label: db.getName(),
resource_type: 'DATABASE'
}];
Updated 15 days ago