winrmntlm

package module
v0.0.0-...-7d8af67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2018 License: MIT Imports: 14 Imported by: 1

README

winrm-auth-ntlm

NTLM Transporter for the masterzen's Go WinRM client.

Comparing to original NTLM implementation, the package allows domain user authentication.

Installation:

go get github.com/dpotapov/winrm-auth-ntlm

Usage:

endpoint := winrm.NewEndpoint(*host, *port, false, false, nil, nil, nil, 0)

winrm.DefaultParameters.TransportDecorator = func() winrm.Transporter {
    return &winrmntlm.Transport{
        Username: *user,
        Password: *pswd,
    }
}

// Note, username/password pair in the NewClientWithParameters call is ignored
client, err := winrm.NewClientWithParameters(endpoint, "", "", winrm.DefaultParameters)
if err != nil {
    panic(err)
}

_, err = client.Run(flag.Arg(0), os.Stdout, os.Stderr)
if err != nil {
    panic(err)
}

Please check the full example in the example directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NegotiateMessage

type NegotiateMessage struct {
	ntlm.NegotiateMessage
}

NegotiateMessage defines an NTLM Negotiate message that is sent from the client to the server. This message allows the client to specify its supported NTLM options to the server.

func NewNegotiateMessage

func NewNegotiateMessage(domain, workstation string) *NegotiateMessage

NewNegotiateMessage creates a new NegotiateMessage for the NTLMv2 protocol. The domain and workstation names, if non-empty, are included into a message to let the server to determine whether the client is eligible for local authentication.

func (*NegotiateMessage) Bytes

func (n *NegotiateMessage) Bytes() []byte

Bytes converts the NegotiateMessage structure into a slice of bytes.

func (*NegotiateMessage) String

func (n *NegotiateMessage) String() string

type Transport

type Transport struct {
	Username   string
	Password   string
	HTTPClient *http.Client
	Endpoint   *winrm.Endpoint
}

Transport implements the winrm.Transporter interface.

func (*Transport) EndpointURL

func (t *Transport) EndpointURL() string

EndpointURL returns a WinRM http(s) URL. It does the same job as unexported method url() for the winrm.Endpoint type.

func (*Transport) Post

func (t *Transport) Post(client *winrm.Client, request *soap.SoapMessage) (string, error)

Post sends a POST request to WinRM server with the provided SOAP payload. If the WinRM web service responds with Unauthorized status, the method performs NTLM authentication.

func (*Transport) Transport

func (t *Transport) Transport(endpoint *winrm.Endpoint) error

Transport applies configuration parameters from the Endpoint to the underlying HTTPClient. If the HTTPClient is nil, a new instance of http.Client will be created.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL