1.5. Users API

The Users API provides utility functions to manage ntopng system users.

Functions

function getUsers()

Get ntopng users information.

Return
ntopng users information.

function addUser(string username, string full_name, string password, string host_role, string allowed_networks, string allowed_interface, string host_pool_id = nil, string language = nil)

Add a new ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the user name to add.
  • full_name: a descriptive user name.
  • password: the user password.
  • host_role: the user group, should be “unprivileged” or “administrator”.
  • allowed_networks: comma separated list of allowed networks for the user. Use “0.0.0.0/0,::/0” for all networks.
  • allowed_interface: the only network interface name that this user case see.
  • host_pool_id: this can be used to create a Captive Portal user.
  • language: user language code.

function deleteUser(string username)

Delete a ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the user to delete.

function getAllowedNetworks()

Get a string representing the networks the current ntopng user is allowed to see.

Return
allowed networks string.

function resetUserPassword(string who, string username, string old_password, string new_password)

Reset a ntopng user password.

Note
the administrator can reset the password regardless of the old_password value.
Return
true on success, false otherwise.
Parameters
  • who: the ntopng user who is requesting the reset.
  • username: the user for the password reset.
  • old_password: the old user password.
  • new_password: the new user password.

function changeUserRole(string username, string user_role)

Change the group of a ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the target user.
  • user_role: the new group, should be “unprivileged” or “administrator”.

function changeAllowedNets(string username, string allowed_networks)

Change the allowed networks of a ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the target user.
  • allowed_networks: the new allowed networks.

function changeAllowedIfname(string username, string allowed_ifname)

Change the allowed interface name of a ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the target user.
  • allowed_ifname: the new allowed interface name for the user.

function changeUserLanguage(string username, string language)

Change the GUI language of a ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the target user.
  • language: the new language code.

function changeUserHostPool(string username, int host_pool_id)

Change the host pool a ntopng user.

Return
true on success, false otherwise.
Parameters
  • username: the target user.
  • host_pool_id: the new host pool ID.

function isAllowedInterface(int ifid)

Check if the provided interface is allowed for the current user.

Return
true if the interface is allowed, false otherwise.
Parameters
  • ifid: the interface ID to check

function isAllowedNetwork(string network)

Check if the provided network is allowed for the current user.

Return
true if the network is allowed, false otherwise.
Parameters
  • network: the network CIDR to check

function getNologinUser()

Get the user name for the “nologin” user.

Return
the nologin user name

function isAdministrator()

Check if the current user is an administrator.

Return
true if the user is administrator, false otherwise.

function isLoginBlacklisted()

Check if the login for the seccion is blacklisted.

Return
true if the login is blacklisted, false otherwise.
Note
An IP address can get blacklisted when too many unsuccesful login attempts are performed.