本文整理汇总了Python中win32security.ImpersonateLoggedOnUser方法的典型用法代码示例。如果您正苦于以下问题:Python win32security.ImpersonateLoggedOnUser方法的具体用法?Python win32security.ImpersonateLoggedOnUser怎么用?Python win32security.ImpersonateLoggedOnUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32security
的用法示例。
在下文中一共展示了win32security.ImpersonateLoggedOnUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: impersonate_user
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import ImpersonateLoggedOnUser [as 别名]
def impersonate_user(self, username, password):
"""Impersonate the security context of another user."""
handler = win32security.LogonUser(
username, None, password,
win32con.LOGON32_LOGON_INTERACTIVE,
win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(handler)
handler.Close()
示例2: impersonate
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import ImpersonateLoggedOnUser [as 别名]
def impersonate(username, password, domain):
if username:
print "Using alternative credentials:"
print "Username: " + str(username)
print "Password: " + str(password)
print "Domain: " + str(domain)
handle = win32security.LogonUser( username, domain, password, win32security.LOGON32_LOGON_NEW_CREDENTIALS, win32security.LOGON32_PROVIDER_WINNT50 )
win32security.ImpersonateLoggedOnUser( handle )
else:
print "Running as current user. No logon creds supplied (-u, -d, -p)."
print
示例3: impersonate_user
# 需要导入模块: import win32security [as 别名]
# 或者: from win32security import ImpersonateLoggedOnUser [as 别名]
def impersonate_user(self, username, password):
"""impersonate user when operating file system
"""
handler = win32security.LogonUser(
username, None, password,
win32con.LOGON32_LOGON_INTERACTIVE,
win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(handler)
handler.Close()