74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/chef/util/windows/logon_session.rb', line 74
def set_user_context
validate_session_open!
unless session_opened
raise "Attempted to set the user context before opening a session."
end
if impersonating
raise "Attempt to set the user context when the user context is already set."
end
status = Chef::ReservedNames::Win32::API::Security.ImpersonateLoggedOnUser(token.read_ulong)
unless status
last_error = FFI::LastError.error
raise Chef::Exceptions::Win32APIError, "Attempt to impersonate user `#{original_username}` failed with Win32 status #{last_error}."
end
@impersonating = true
end
|