ldap

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const FAKE_HOST string = "FAKE"

Variables

View Source
var (
	// ErrClosed is the error resulting if the pool is closed via pool.Close().
	ErrClosed = errors.New("pool is closed")
)
View Source
var ErrInvalidCredentials = errors.New("invalid credentials")
View Source
var ErrUserAlreadyExisted = errors.New("user already existed")
View Source
var ErrUserNotExists = errors.New("user not exists")

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Create create a new user in ldap
	Create(user *iamv1alpha2.User) error

	// Update updates a user information, return error if user not exists
	Update(user *iamv1alpha2.User) error

	// Delete deletes a user from ldap, return nil if user not exists
	Delete(name string) error

	// Get gets a user by its username from ldap, return ErrUserNotExists if user not exists
	Get(name string) (*iamv1alpha2.User, error)

	// Authenticate checks if (name, password) is valid, return ErrInvalidCredentials if not
	Authenticate(name string, password string) error

	List(query *query.Query) (*api.ListResult, error)
}

Interface defines CRUD behaviors of manipulating users

func NewLdapClient

func NewLdapClient(options *Options, stopCh <-chan struct{}) (Interface, error)

func NewSimpleLdap

func NewSimpleLdap() Interface

type Options

type Options struct {
	Host            string `json:"host,omitempty" yaml:"host"`
	ManagerDN       string `json:"managerDN,omitempty" yaml:"managerDN"`
	ManagerPassword string `json:"managerPassword,omitempty" yaml:"managerPassword"`
	UserSearchBase  string `json:"userSearchBase,omitempty" yaml:"userSearchBase"`
	GroupSearchBase string `json:"groupSearchBase,omitempty" yaml:"groupSearchBase"`
	InitialCap      int    `json:"initialCap,omitempty" yaml:"initialCap"`
	MaxCap          int    `json:"maxCap,omitempty" yaml:"maxCap"`
	PoolName        string `json:"poolName,omitempty" yaml:"poolName"`
}

func NewOptions

func NewOptions() *Options

NewOptions return a default option which host field point to nowhere.

func (*Options) AddFlags

func (l *Options) AddFlags(fs *pflag.FlagSet, s *Options)

func (*Options) ApplyTo

func (l *Options) ApplyTo(options *Options)

func (*Options) Validate

func (l *Options) Validate() []error

type Pool

type Pool interface {
	// Get returns a new connection from the pool. Closing the connections puts
	// it back to the Pool. Closing it when the pool is destroyed or full will
	// be counted as an error.
	Get() (*PoolConn, error)

	// Close closes the pool and all its connections. After Close() the pool is
	// no longer usable.
	Close()

	// Len returns the current number of connections of the pool.
	Len() int
}

Pool interface describes a pool implementation. A pool should have maximum capacity. An ideal pool is threadsafe and easy to use.

type PoolConn

type PoolConn struct {
	Conn ldap.Client
	// contains filtered or unexported fields
}

PoolConn implements Client to override the Close() method

func (*PoolConn) Add

func (p *PoolConn) Add(addRequest *ldap.AddRequest) error

func (*PoolConn) Bind

func (p *PoolConn) Bind(username, password string) error

func (*PoolConn) Close

func (p *PoolConn) Close()

Close() puts the given connects back to the pool instead of closing it.

func (*PoolConn) Compare

func (p *PoolConn) Compare(dn, attribute, value string) (bool, error)

func (*PoolConn) Del

func (p *PoolConn) Del(delRequest *ldap.DelRequest) error

func (*PoolConn) MarkUnusable

func (p *PoolConn) MarkUnusable()

MarkUnusable() marks the connection not usable any more, to let the pool close it instead of returning it to pool.

func (*PoolConn) Modify

func (p *PoolConn) Modify(modifyRequest *ldap.ModifyRequest) error

func (*PoolConn) ModifyDN

func (p *PoolConn) ModifyDN(modifyDNRequest *ldap.ModifyDNRequest) error

func (*PoolConn) PasswordModify

func (p *PoolConn) PasswordModify(passwordModifyRequest *ldap.PasswordModifyRequest) (*ldap.PasswordModifyResult, error)

func (*PoolConn) Search

func (p *PoolConn) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

func (*PoolConn) SearchWithPaging

func (p *PoolConn) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (*ldap.SearchResult, error)

func (*PoolConn) SetTimeout

func (p *PoolConn) SetTimeout(t time.Duration)

func (*PoolConn) SimpleBind

func (p *PoolConn) SimpleBind(simpleBindRequest *ldap.SimpleBindRequest) (*ldap.SimpleBindResult, error)

func (*PoolConn) Start

func (p *PoolConn) Start()

func (*PoolConn) StartTLS

func (p *PoolConn) StartTLS(config *tls.Config) error

type PoolFactory

type PoolFactory func(string) (ldap.Client, error)

PoolFactory is a function to create new connections.

Jump to

Keyboard shortcuts

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