本文整理汇总了Python中sec1httplib.requestbuilder.Requestobj.find_data方法的典型用法代码示例。如果您正苦于以下问题:Python Requestobj.find_data方法的具体用法?Python Requestobj.find_data怎么用?Python Requestobj.find_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sec1httplib.requestbuilder.Requestobj
的用法示例。
在下文中一共展示了Requestobj.find_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_is_admin
# 需要导入模块: from sec1httplib.requestbuilder import Requestobj [as 别名]
# 或者: from sec1httplib.requestbuilder.Requestobj import find_data [as 别名]
def user_is_admin(self,username,password):
if self.splunkd == 1:
# attempt to auth via splunkd to get a sessionkey
self.username = username
self.password = password
self.splunkd_auth()
url = Requestobj("{0}/services/authentication/httpauth-tokens".format(self.splunkd_url))
url.basic_auth(username,password)
context = url.makerequest()
if '<title>httpauth-tokens' in context.body:
self.got_admin =1
return True
else:
return False
elif self.splunkweb == 1:
with misc_lock:
self.username = username
self.password = password
if self.splunkweb_auth():
admin_only = Requestobj("{0}/en-US/manager/launcher/server/settings/settings?action=edit".format(self.splunkweb_url)).makerequest()
if admin_only.find_data("Port that Splunk Web uses"):
print "[i] User:{0} IS AN ADMIN.".format(username)
return True
else:
print "[i] User:{0} is not an admin".format(username)
else:
pass
else:
print "Not Connected"
return False