summaryrefslogtreecommitdiff
path: root/lib/chef/util/windows/net_user.rb
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-08 13:01:53 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-15 08:51:21 -0700
commit7f6631c20c71ff23cca265ae844f931cd2bd2776 (patch)
tree531f098421fb7cd814f8d5c4e47a92404a26bb36 /lib/chef/util/windows/net_user.rb
parente90ff3c513b8f3dcbb55a769a2aece2fc0e15cd9 (diff)
downloadchef-7f6631c20c71ff23cca265ae844f931cd2bd2776.tar.gz
LogonUser uses ffi instead win32-api
Diffstat (limited to 'lib/chef/util/windows/net_user.rb')
-rw-r--r--lib/chef/util/windows/net_user.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb
index b98f346f51..26fbe53db6 100644
--- a/lib/chef/util/windows/net_user.rb
+++ b/lib/chef/util/windows/net_user.rb
@@ -19,6 +19,7 @@
require 'chef/util/windows'
require 'chef/exceptions'
require 'chef/win32/net'
+require 'chef/win32/security'
#wrapper around a subset of the NetUser* APIs.
#nothing Chef specific, but not complete enough to be its own gem, so util for now.
@@ -26,8 +27,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
private
NetUser = Chef::ReservedNames::Win32::NetUser
-
- LogonUser = Windows::API.new('LogonUser', 'SSSLLP', 'I', 'advapi32')
+ Security = Chef::ReservedNames::Win32::Security
USER_INFO_3_TRANSFORM = {
name: :usri3_name,
@@ -91,18 +91,17 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows
@name = multi_to_wide(username)
end
- LOGON32_PROVIDER_DEFAULT = 0
- LOGON32_LOGON_NETWORK = 3
+ LOGON32_PROVIDER_DEFAULT = Security::LOGON32_PROVIDER_DEFAULT
+ LOGON32_LOGON_NETWORK = Security::LOGON32_LOGON_NETWORK
#XXX for an extra painful alternative, see: http://support.microsoft.com/kb/180548
def validate_credentials(passwd)
- token = 0.chr * PTR_SIZE
- res = LogonUser.call(@username, nil, passwd,
- LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, token)
- if res == 0
+ begin
+ token = Security::logon_user(@username, nil, passwd,
+ LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT)
+ return true
+ rescue Chef::Exceptions::Win32APIError
return false
end
- ::Windows::Handle::CloseHandle.call(token.unpack('L')[0])
- return true
end
def get_info