Fetch the repository succeeded.
from ise_api_0_login_info import username, password, url_prefix, headers
from ise_api_3_group import get_group_detail_by_id
import requests
from requests.auth import HTTPBasicAuth
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
getall_url = 'config/internaluser'
def get_all_user():
r = requests.get(url_prefix + getall_url, auth=HTTPBasicAuth(username, password), headers=headers, verify=False)
# print(r.json())
user_list = []
for x in r.json()['SearchResult']['resources']:
user_list.append({'username': x.get('name'), 'id': x.get('id'), 'url': x.get('link').get('href')})
return user_list
def get_user_detail(user_name):
for user in get_all_user():
if user.get('username') == user_name:
# print(user.get('url'))
r = requests.get(user.get('url'),
auth=HTTPBasicAuth(username, password),
headers=headers,
verify=False)
user_data = r.json().get('InternalUser')
if user_data.get('identityGroups', ''):
return {'username': user_name,
'id': user_data.get('id'),
'enable': user_data.get('enabled'),
'url': user.get('url'),
'group': get_group_detail_by_id(user_data.get('identityGroups')).get('name')}
else:
return {'username': user_name,
'id': user_data.get('id'),
'enable': user_data.get('enabled'),
'url': user.get('url')}
if __name__ == "__main__":
# print(get_all_user())
print(get_user_detail('iseuser'))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。