x2gobroker.nameservices.base_nameservice module

class x2gobroker.nameservices.base_nameservice.X2GoBrokerNameService[source]

Bases: object

get_group_members(group, primary_groups=False)[source]

Retrieve a list of users being members of a given group.

Optionally, primary group memberships can be considered (or not).

Parameters
  • group (str) – name of the group to retrieve members of

  • primary_groups (bool) – take primary group membership into consideration or not

Returns

list of users that are members of the given group

Return type

list

get_groups()[source]

Retrieve list of groups known to the broker.

Returns

list of known group names

Return type

list

get_primary_group(username)[source]

Get the primary group of a given user. If the nameservices backend in use does not support primary groups, an empty string will be returned.

Parameters

username (str) – name of the user to get the primary group for

Returns

name of the primary group of the given user

Return type

str

get_user_groups(username, primary_groups=False)[source]

Retrieve a list of groups that a given user is member of.

Optionally, primary group memberships can be considered (or not).

Parameters
  • username (str) – name of the user to retrieve groupm memberships of

  • primary_groups (bool) – take primary group membership into consideration or not

Returns

list of groups that the given user is member of

Return type

list

get_users()[source]

Retrieve list of users known to the broker.

Returns

list of known user names

Return type

list

has_group(group)[source]

Provide information, if the broker knows a given group (or not).

Parameters

group (str) – name of the group to check

Returns

True if the group is known to the broker, False if not

Return type

bool

has_user(username)[source]

Provide information, if the broker knows a given user (or not).

Parameters

username (str) – name of the user to check

Returns

True if the user is known to the broker, False if not

Return type

bool

is_group_member(username, group, primary_groups=False)[source]

Check, if a given user is member of a given group.

Optionally, primary group memberships can be considered (or not).

Parameters
  • username (str) – name of the user to check

  • group (str) – name of the group to check

  • primary_groups (bool) – take primary group membership into consideration or not

Returns

True if the user is member of the given group, False if not

Return type

bool