diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-27 15:05:20 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-08-28 17:19:35 -0700 |
commit | 093e2cb93d5f8e14fc86d6eb67f174945b7b05af (patch) | |
tree | 3e3b24ba68b6458a8f12a7dadb9ee424edf6bea0 /lib/chef/win32 | |
parent | 895c8718463029135cc1fe9b3084ff25957ac94d (diff) | |
download | chef-093e2cb93d5f8e14fc86d6eb67f174945b7b05af.tar.gz |
FFI NetUseGetInfo
Diffstat (limited to 'lib/chef/win32')
-rw-r--r-- | lib/chef/win32/api/net.rb | 22 | ||||
-rw-r--r-- | lib/chef/win32/net.rb | 16 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb index 90154e7661..b4be47e418 100644 --- a/lib/chef/win32/api/net.rb +++ b/lib/chef/win32/api/net.rb @@ -154,6 +154,21 @@ class Chef layout :lgrpi0_name, :LPWSTR end + class USE_INFO_2 < FFI::Struct + include StructHelpers + + layout :ui2_local, :LMSTR, + :ui2_remote, :LMSTR, + :ui2_password, :LMSTR, + :ui2_status, :DWORD, + :ui2_asg_type, :DWORD, + :ui2_refcount, :DWORD, + :ui2_usecount, :DWORD, + :ui2_username, :LPWSTR, + :ui2_domainname, :LMSTR + end + + #NET_API_STATUS NetLocalGroupAdd( #_In_ LPCWSTR servername, #_In_ DWORD level, @@ -287,6 +302,13 @@ class Chef #); safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD +#NET_API_STATUS NetUseGetInfo( + #_In_ LMSTR UncServerName, + #_In_ LMSTR UseName, + #_In_ DWORD Level, + #_Out_ LPBYTE *BufPtr +#); + safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD end end end diff --git a/lib/chef/win32/net.rb b/lib/chef/win32/net.rb index e481be7ddb..2520e7a117 100644 --- a/lib/chef/win32/net.rb +++ b/lib/chef/win32/net.rb @@ -306,6 +306,22 @@ END net_api_error!(rc) end end + + def self.net_use_get_info_l2(server_name, use_name) + server_name = wstring(server_name) + use_name = wstring(use_name) + ui2_p = FFI::MemoryPointer.new(:pointer) + + rc = NetUseGetInfo(server_name, use_name, 2, ui2_p) + if rc != NERR_Success + net_api_error!(rc) + end + + ui2 = USE_INFO_2.new(ui2_p.read_pointer).as_ruby + NetApiBufferFree(ui2_p.read_pointer) + + ui2 + end end NetUser = Net # For backwards compatibility end |