qgis_deployment_toolbelt.utils.user_groups module

Utilities to manage user security groups either on Linux and Windows.

Author: Julien Moura (https://github.com/guts)

qgis_deployment_toolbelt.utils.user_groups.get_user_domain_groups(user_name: str | None = None) list[str]

Lists the domain groups to which the user belong.

On Linux and MacOS, it always return an empty list. TODO: implement it (probably

using pure LDAP).

On Windows, it relies on win32net (COM).

Parameters:

user_name (str | None, optional) – name of user. If None, the current user name is used. Defaults to None.

Raises:

NotImplementedError – if operating system is not supported.

Returns:

sorted list of unique groups names

Return type:

list[str]

qgis_deployment_toolbelt.utils.user_groups.get_user_local_groups(user_name: str | None = None) list[str]

Lists the local groups to which the user belong.

On Linux and MacOS, it relies on the grp module (only available). On Windows, it relies on win32net (COM).

Parameters:

user_name (str | None, optional) – name of user. If None, the current user name is used. Defaults to None.

Raises:

NotImplementedError – if operating system is not supported.

Returns:

sorted list of unique groups names

Return type:

list[str]

qgis_deployment_toolbelt.utils.user_groups.is_computer_attached_to_a_domain() bool

Determine if the computer is attached to a domain or not.

On Linux and MacOS, it always return False. On Windows, it tries to use wmi (Windows Management Instrumentation), Active

Directory (through pyad) or subprocessed powershell as final fallback.

Raises:

NotImplementedError – if operating system is not supported.

Returns:

True if the computer is attached to a domain.

Return type:

bool

qgis_deployment_toolbelt.utils.user_groups.is_user_in_group(group_name: str, user_name: str | None = None) bool

Check if a user is a member of a specified group.

Parameters:
  • user_name (str | None, optional) – The username to check. If None, the current user name is used. Defaults to None.

  • group_name (str) – The name of the group to check membership.

Returns:

True if the user is a member of the group, False otherwise or if

something fails.

Return type:

bool