Documentation
¶
Index ¶
- Variables
- func Dial(opts *DialOptions) (conn net.Conn, err error)
- func ListSupportedAuthTypes(quote bool) []string
- type AuthType
- type BindParameters
- func (p *BindParameters) FromKeyring() error
- func (p *BindParameters) SetDefaults()
- func (p *BindParameters) SetDomain(domain string) *BindParameters
- func (p *BindParameters) SetPassword(password string) *BindParameters
- func (p *BindParameters) SetType(authType AuthType) *BindParameters
- func (p *BindParameters) SetUser(user string) *BindParameters
- func (p BindParameters) ToKeyring() error
- func (p *BindParameters) Validate() error
- type Connection
- type DialOptions
- func (o *DialOptions) SetDefaults()
- func (o *DialOptions) SetMaxRetries(retries uint) *DialOptions
- func (o *DialOptions) SetSizeLimit(limit int64) *DialOptions
- func (o *DialOptions) SetTLSConfig(conf *tls.Config) *DialOptions
- func (o *DialOptions) SetTimeLimit(limit time.Duration) *DialOptions
- func (o *DialOptions) SetURL(addr string) *DialOptions
- func (o *DialOptions) Validate() error
- type GSSAPIClient
- func (c *GSSAPIClient) DeleteSecContext() error
- func (c *GSSAPIClient) InitSecContext(target string, token []byte) (outputToken []byte, needContinue bool, err error)
- func (c *GSSAPIClient) InitSecContextWithOptions(target string, token []byte, options []int) (outputToken []byte, needContinue bool, err error)
- func (c *GSSAPIClient) NegotiateSaslAuth(token []byte, authzID string) ([]byte, error)
- type Port
- type Scheme
- type URL
Constants ¶
This section is empty.
Variables ¶
var ErrNoKerberosClient = fmt.Errorf("GSSAPIClient: no Kerberos client configured")
ErrNoKerberosClient is returned if the GSSAPIClient is not initialized with a Kerberos client
Functions ¶
func ListSupportedAuthTypes ¶
Types ¶
type AuthType ¶
type AuthType int
AuthType is an LDAP authentication type (RFC 4511)
type BindParameters ¶
type BindParameters struct {
// AuthType is the authentication type
AuthType AuthType `validate:"required,is_valid"` // default: SIMPLE
// Domain is user's domain (for NTLM authentication)
Domain string
// Use NTLM hash instead of password
AsHash bool
// User's password
Password string `validate:"required_unless=AuthType UNAUTHENTICATED"`
// Username
User string `validate:"required_unless=AuthType UNAUTHENTICATED"`
}
BindParameters are parameters for binding to the server
func NewBindParameters ¶
func NewBindParameters() *BindParameters
NewBindParameters creates a new BindParameters instance
func (*BindParameters) FromKeyring ¶
func (p *BindParameters) FromKeyring() error
FromKeyring loads credentials from keyring
func (*BindParameters) SetDefaults ¶
func (p *BindParameters) SetDefaults()
SetDefaults sets default values
func (*BindParameters) SetDomain ¶
func (p *BindParameters) SetDomain(domain string) *BindParameters
SetDomain sets domain (required for NTLM-based authentication)
func (*BindParameters) SetPassword ¶
func (p *BindParameters) SetPassword(password string) *BindParameters
SetPassword sets password
func (*BindParameters) SetType ¶
func (p *BindParameters) SetType(authType AuthType) *BindParameters
SetType sets authentication type
func (*BindParameters) SetUser ¶
func (p *BindParameters) SetUser(user string) *BindParameters
SetUser sets username
func (BindParameters) ToKeyring ¶
func (p BindParameters) ToKeyring() error
ToKeyring saves credentials to keyring
func (*BindParameters) Validate ¶
func (p *BindParameters) Validate() error
Validate validates bind parameters
type Connection ¶
type Connection struct {
// LDAP connection
*ldap.Conn
// Dial options
*DialOptions
// contains filtered or unexported fields
}
Connection object
func Bind ¶
func Bind(parameters *BindParameters, options *DialOptions) (*Connection, error)
Bind establishes a connection to the server and binds to it
func (Connection) Close ¶
func (c Connection) Close() error
Close closes the underlying TCP connection
func (Connection) RemoteHost ¶
func (c Connection) RemoteHost() string
RemoteHost returns the remote host of the domain controller
type DialOptions ¶
type DialOptions struct {
// Number of max retries if failing
MaxRetries uint `validate:"required" default:"3"`
// Limits number of objects returned by an LDAP query
SizeLimit int64
// Timeout for connection handshake and LDAP queries
TimeLimit time.Duration `validate:"required" default:"10s"`
// Custom TLS config
TLSConfig *tls.Config
// Server URL
URL *URL `validate:"required,is_valid"` // default: ldap://localhost:389
}
Options for dialer
func (*DialOptions) SetMaxRetries ¶
func (o *DialOptions) SetMaxRetries(retries uint) *DialOptions
SetMaxRetries sets max retries
func (*DialOptions) SetSizeLimit ¶
func (o *DialOptions) SetSizeLimit(limit int64) *DialOptions
SetSizeLimit sets size limit
func (*DialOptions) SetTLSConfig ¶
func (o *DialOptions) SetTLSConfig(conf *tls.Config) *DialOptions
SetTLSConfig sets TLS config
func (*DialOptions) SetTimeLimit ¶
func (o *DialOptions) SetTimeLimit(limit time.Duration) *DialOptions
SetTimeLimit sets time limit
type GSSAPIClient ¶ added in v2.6.6
type GSSAPIClient struct {
// contains filtered or unexported fields
}
GSSAPIClient implements ldap.GSSAPIClient using gokrb5 for Kerberos authentication
func (*GSSAPIClient) DeleteSecContext ¶ added in v2.6.6
func (c *GSSAPIClient) DeleteSecContext() error
DeleteSecContext cleans up the GSSAPI context
func (*GSSAPIClient) InitSecContext ¶ added in v2.6.6
func (c *GSSAPIClient) InitSecContext(target string, token []byte) (outputToken []byte, needContinue bool, err error)
InitSecContext initiates the GSSAPI context establishment for SASL bind
func (*GSSAPIClient) InitSecContextWithOptions ¶ added in v2.7.4
func (c *GSSAPIClient) InitSecContextWithOptions(target string, token []byte, options []int) (outputToken []byte, needContinue bool, err error)
InitSecContextWithOptions initiates the GSSAPI context with options (unused for now)
func (*GSSAPIClient) NegotiateSaslAuth ¶ added in v2.6.6
func (c *GSSAPIClient) NegotiateSaslAuth(token []byte, authzID string) ([]byte, error)
NegotiateSaslAuth finalizes the SASL negotiation (not used for most LDAP GSSAPI flows)
type Port ¶
type Port int
const ( // LDAP_RW is the default LDAP port (local catalogue port) LDAP_RW Port = 389 // LDAP_RO is the global catalogue port LDAP_RO Port = 3268 // LDAPS_RW is the default LDAP port over TLS (local catalogue port) LDAPS_RW Port = 636 // LDAPS_RO is the global catalogue port over TLS LDAPS_RO Port = 3269 )
type URL ¶
type URL struct {
// Scheme
Scheme Scheme `validate:"required,is_valid"`
// Server's domain name
Host string `validate:"required"`
// Server's port
Port Port `validate:"excluded_if=Scheme ldapi,required_unless=Scheme ldapi"`
}
URL is a URL (RFC 4516)
func URLFromString ¶
URLFromString returns an URL from a string (<scheme>://<hostname>:<port>)
func (URL) String ¶
String returns the string representation of an URL (<scheme>://<hostname>:<?port>)
func (URL) ToBaseDirectoryPath ¶
ToBaseDirectoryPath builds base DN from host