本文整理匯總了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()