ldap

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_LDAP
	LDAP_CONTEXT_ERROR
	LDAP_SERVER_CONFIG
	LDAP_SERVER_DIAL
	LDAP_SERVER_TLS
	LDAP_SERVER_STARTTLS
	LDAP_BIND
	LDAP_SEARCH
	LDAP_USER_NOT_UNIQ
	LDAP_USER_NOT_FOUND
)

Variables

This section is empty.

Functions

func GetDefaultAttributes

func GetDefaultAttributes() []string

func IsCodeError

func IsCodeError() bool

Types

type Config

type Config struct {
	Uri         string `cloud:"uri" mapstructure:"uri" json:"uri" yaml:"uri" toml:"uri"`
	PortLdap    int    `cloud:"port-ldap" mapstructure:"port-ldap" json:"port-ldap" yaml:"port-ldap" toml:"port-ldap"`
	Portldaps   int    `cloud:"port-ldaps" mapstructure:"port-ldaps" json:"port-ldaps" yaml:"port-ldaps" toml:"port-ldaps"`
	Basedn      string `cloud:"basedn" mapstructure:"basedn" json:"basedn" yaml:"basedn" toml:"basedn"`
	FilterGroup string `cloud:"filter-group" mapstructure:"filter-group" json:"filter-group" yaml:"filter-group" toml:"filter-group"`
	FilterUser  string `cloud:"filter-user" mapstructure:"filter-user" json:"filter-user" yaml:"filter-user" toml:"filter-user"`
}

func NewConfig

func NewConfig() *Config

func (Config) BaseDN

func (cnf Config) BaseDN() string

func (Config) Clone

func (cnf Config) Clone() *Config

func (Config) PatternFilterGroup

func (cnf Config) PatternFilterGroup() string

func (Config) PatternFilterUser

func (cnf Config) PatternFilterUser() string

func (Config) ServerAddr

func (cnf Config) ServerAddr(withTls bool) string

type HelperLDAP

type HelperLDAP struct {
	Attributes []string
	// contains filtered or unexported fields
}

HelperLDAP struct use to manage connection to server and request it

func NewLDAP

func NewLDAP(ctx context.Context, cnf *Config, attributes []string) (*HelperLDAP, errors.Error)

NewLDAP build a new LDAP helper based on config struct given

func (*HelperLDAP) AuthUser

func (lc *HelperLDAP) AuthUser(username, password string) errors.Error

AuthUser used to test bind given user uid and password

func (*HelperLDAP) Check

func (lc *HelperLDAP) Check() errors.Error

Check used to check if connection success (without any bind)

func (*HelperLDAP) Close

func (lc *HelperLDAP) Close()

Close used to close connection object

func (*HelperLDAP) Connect

func (lc *HelperLDAP) Connect() errors.Error

Connect used to connect and bind to server

func (*HelperLDAP) ForceTLSMode

func (lc *HelperLDAP) ForceTLSMode(tlsMode TLSMode, tlsConfig *tls.Config)

SetCredentials used to defined the BindDN and password for connection

func (HelperLDAP) ParseEntries

func (lc HelperLDAP) ParseEntries(entry string) map[string][]string

ParseEntries used to clean attributes of an object class

func (*HelperLDAP) SetCredentials

func (lc *HelperLDAP) SetCredentials(user, pass string)

SetCredentials used to defined the BindDN and password for connection

func (*HelperLDAP) UserInfo

func (lc *HelperLDAP) UserInfo(username string) (map[string]string, errors.Error)

UserInfo used to retrieve the information of a given username

func (*HelperLDAP) UserIsInGroup

func (lc *HelperLDAP) UserIsInGroup(username string, groupname []string) (bool, errors.Error)

UserIsInGroup used to check if a given username is a group member of a list of reference group name

func (*HelperLDAP) UserMemberOf

func (lc *HelperLDAP) UserMemberOf(username string) ([]string, errors.Error)

UserMemberOf returns the group list of a given user.

func (*HelperLDAP) UsersOfGroup

func (lc *HelperLDAP) UsersOfGroup(groupname string) ([]string, errors.Error)

UsersOfGroup used to retrieve the member list of a given group name

type TLSMode

type TLSMode uint8
const (

	//TLSModeNone no tls connection
	TLSMODE_NONE TLSMode = iota + 1
	//TLSModeTLS strict tls connection
	TLSMODE_TLS
	//TLSModeStartTLS starttls connection (tls into a no tls connection)
	TLSMODE_STARTTLS
)

func (TLSMode) String

func (m TLSMode) String() string

Jump to

Keyboard shortcuts

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