diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-05-08 13:01:53 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-05-15 08:51:21 -0700 |
commit | 7f6631c20c71ff23cca265ae844f931cd2bd2776 (patch) | |
tree | 531f098421fb7cd814f8d5c4e47a92404a26bb36 /lib/chef/win32/security.rb | |
parent | e90ff3c513b8f3dcbb55a769a2aece2fc0e15cd9 (diff) | |
download | chef-7f6631c20c71ff23cca265ae844f931cd2bd2776.tar.gz |
LogonUser uses ffi instead win32-api
Diffstat (limited to 'lib/chef/win32/security.rb')
-rw-r--r-- | lib/chef/win32/security.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb index 3902d8caaf..a5a845e55c 100644 --- a/lib/chef/win32/security.rb +++ b/lib/chef/win32/security.rb @@ -22,6 +22,7 @@ require 'chef/win32/memory' require 'chef/win32/process' require 'chef/win32/unicode' require 'chef/win32/security/token' +require 'chef/mixin/wstring' class Chef module ReservedNames::Win32 @@ -31,6 +32,8 @@ class Chef include Chef::ReservedNames::Win32::API::Security extend Chef::ReservedNames::Win32::API::Security extend Chef::ReservedNames::Win32::API::Macros + include Chef::Mixin::WideString + extend Chef::Mixin::WideString def self.access_check(security_descriptor, token, desired_access, generic_mapping) token_handle = token.handle.handle @@ -543,6 +546,18 @@ class Chef success && (elevation_result.read_ulong != 0) end end + + def self.logon_user(username, domain, password, logon_type, logon_provider) + username = wstring(username) + domain = wstring(domain) + password = wstring(password) + + token = FFI::Buffer.new(:pointer) + unless LogonUserW(username, domain, password, logon_type, logon_provider, token) + Chef::ReservedNames::Win32::Error.raise! + end + Token.new(Handle.new(token.read_pointer)) + end end end end |