1.5. Users API

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

Functions

function getUsers()

Get ntopng users information.

Returns:

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.

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.

Returns:

true on success, false otherwise.

function deleteUser(string username)

Delete a ntopng user.

Parameters:

username – the user to delete.

Returns:

true on success, false otherwise.

function getAllowedNetworks()

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

Returns:

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.

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.

Returns:

true on success, false otherwise.

function changeUserRole(string username, string user_role)

Change the group of a ntopng user.

Parameters:
  • username – the target user.

  • user_role – the new group, should be “unprivileged” or “administrator”.

Returns:

true on success, false otherwise.

function changeAllowedNets(string username, string allowed_networks)

Change the allowed networks of a ntopng user.

Parameters:
  • username – the target user.

  • allowed_networks – the new allowed networks.

Returns:

true on success, false otherwise.

function changeAllowedIfname(string username, string allowed_ifname)

Change the allowed interface name of a ntopng user.

Parameters:
  • username – the target user.

  • allowed_ifname – the new allowed interface name for the user.

Returns:

true on success, false otherwise.

function changeUserLanguage(string username, string language)

Change the GUI language of a ntopng user.

Parameters:
  • username – the target user.

  • language – the new language code.

Returns:

true on success, false otherwise.

function changeUserHostPool(string username, int host_pool_id)

Change the host pool a ntopng user.

Parameters:
  • username – the target user.

  • host_pool_id – the new host pool ID.

Returns:

true on success, false otherwise.

function isAllowedInterface(int ifid)

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

Parameters:

ifid – the interface ID to check

Returns:

true if the interface is allowed, false otherwise.

function isAllowedNetwork(string network)

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

Parameters:

network – the network CIDR to check

Returns:

true if the network is allowed, false otherwise.

function getNologinUser()

Get the user name for the “nologin” user.

Returns:

the nologin user name

function isAdministrator()

Check if the current user is an administrator.

Returns:

true if the user is administrator, false otherwise.

function isLoginBlacklisted()

Check if the login for the seccion is blacklisted.

Note

An IP address can get blacklisted when too many unsuccesful login attempts are performed.

Returns:

true if the login is blacklisted, false otherwise.