def get_users_assigned_to_privilege(self, privilege_id, max_results=None):
self.clean_error()<EOL>if max_results is None:<EOL><INDENT>max_results = self.max_results if self.max_results > <NUM_LIT:1000> else <NUM_LIT:1000><EOL><DEDENT>try:<EOL><INDENT>url = self.get_url(Constants.GET_USERS_ASSIGNED_TO_PRIVILEGE_URL, privilege_id)<EOL>user_ids = []<EOL>response = None<EOL>after_cursor = None<EOL>query_parameters = None<EOL>while (not response) or (len(user_ids) < max_results and after_cursor):<EOL><INDENT>response = self.execute_call('<STR_LIT>', url, params=query_parameters)<EOL>if response.status_code == <NUM_LIT:200>:<EOL><INDENT>json_data = response.json()<EOL>if json_data and '<STR_LIT>' in json_data:<EOL><INDENT>if len(user_ids) + len(json_data['<STR_LIT>']) < max_results:<EOL><INDENT>user_ids += json_data['<STR_LIT>']<EOL><DEDENT>elif len(user_ids) + len(json_data['<STR_LIT>']) == max_results:<EOL><INDENT>user_ids += json_data['<STR_LIT>']<EOL>return user_ids<EOL><DEDENT>else:<EOL><INDENT>for user_id in json_data['<STR_LIT>']:<EOL><INDENT>if len(user_ids) < max_results:<EOL><INDENT>user_ids.append(user_id)<EOL><DEDENT>else:<EOL><INDENT>return user_ids<EOL><DEDENT><DEDENT><DEDENT><DEDENT>after_cursor = self.get_after_cursor(response)<EOL>if after_cursor:<EOL><INDENT>if not query_parameters:<EOL><INDENT>query_parameters = {}<EOL><DEDENT>query_parameters['<STR_LIT>'] = after_cursor<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.error = str(response.status_code)<EOL>self.error_description = self.extract_error_message_from_response(response)<EOL>break<EOL><DEDENT><DEDENT>return user_ids<EOL><DEDENT>except Exception as e:<EOL><INDENT>self.error = <NUM_LIT><EOL>self.error_description = e.args[<NUM_LIT:0>]<EOL><DEDENT>
Gets a list of the users assigned to a privilege.

:param privilege_id: The id of the privilege.
:type privilege_id: string

:param max_results: Limit the number of users returned (optional)
:type max_results: int

Returns the list of users
:return: user_ids list
:rtype: list[int]

See https://developers.onelogin.com/api-docs/1/privileges/get-users Get Assigned Users documentation