Module: RubySMB::Dcerpc::Dfsnm

Defined in:
lib/ruby_smb/dcerpc/dfsnm.rb,
lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_request.rb,
lib/ruby_smb/dcerpc/dfsnm/netr_dfs_add_std_root_response.rb,
lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_request.rb,
lib/ruby_smb/dcerpc/dfsnm/netr_dfs_remove_std_root_response.rb

Defined Under Namespace

Classes: NetrDfsAddStdRootRequest, NetrDfsAddStdRootResponse, NetrDfsRemoveStdRootRequest, NetrDfsRemoveStdRootResponse

Constant Summary collapse

UUID =
'4fc742e0-4a10-11cf-8273-00aa004ae673'
VER_MAJOR =
3
VER_MINOR =
0
NETR_DFS_ADD_STD_ROOT =

Operation numbers

0x000c
NETR_DFS_REMOVE_STD_ROOT =
0x000d

Instance Method Summary collapse

Instance Method Details

#netr_dfs_add_std_root(server_name, root_share, comment: '') ⇒ Object

Create a new stand-alone DFS namespace.

Parameters:

  • server_name (String)

    The host name of the DFS root target.

  • root_share (String)

    The DFS root target share name.

  • comment (String) (defaults to: '')

    A comment associated with the DFS namespace.

Returns:

  • nothing is returned on success

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ruby_smb/dcerpc/dfsnm.rb', line 28

def netr_dfs_add_std_root(server_name, root_share, comment: '')
  netr_dfs_add_std_root_request = NetrDfsAddStdRootRequest.new(
    server_name: server_name,
    root_share: root_share,
    comment: comment
  )
  response = dcerpc_request(netr_dfs_add_std_root_request)
  begin
    netr_dfs_add_std_root_response = NetrDfsAddStdRootResponse.read(response)
  rescue IOError
    raise RubySMB::Dcerpc::Error::InvalidPacket, 'Error reading NetrDfsAddStdRootResponse'
  end
  unless netr_dfs_add_std_root_response.error_status == WindowsError::Win32::ERROR_SUCCESS
    status_code = WindowsError::Win32.find_by_retval(netr_dfs_add_std_root_response.error_status.value).first
    raise RubySMB::Dcerpc::Error::DfsnmError.new(
      "Error returned with netr_dfs_add_std_root: #{status_code}",
      status_code: status_code
    )
  end

  nil
end

#netr_dfs_remove_std_root(server_name, root_share) ⇒ Object

Delete the specified stand-alone DFS namespace.

Parameters:

  • server_name (String)

    The host name of the DFS root target.

  • root_share (String)

    The DFS root target share name.

Returns:

  • nothing is returned on success

Raises:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ruby_smb/dcerpc/dfsnm.rb', line 60

def netr_dfs_remove_std_root(server_name, root_share)
  netr_dfs_remove_std_root_request = NetrDfsRemoveStdRootRequest.new(
    server_name: server_name,
    root_share: root_share
  )
  response = dcerpc_request(netr_dfs_remove_std_root_request)
  begin
    netr_dfs_remove_std_root_response = NetrDfsRemoveStdRootResponse.read(response)
  rescue IOError
    raise RubySMB::Dcerpc::Error::InvalidPacket, 'Error reading NetrDfsRemoveStdRootResponse'
  end
  unless netr_dfs_remove_std_root_response.error_status == WindowsError::Win32::ERROR_SUCCESS
    status_code = WindowsError::Win32.find_by_retval(netr_dfs_remove_std_root_response.error_status.value).first
    raise RubySMB::Dcerpc::Error::DfsnmError.new(
      "Error returned with netr_dfs_remove_std_root: #{status_code}",
      status_code: status_code
    )
  end

  nil
end