ldappool

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 16 Imported by: 0

README

Connection Pooling for LDAP

This ldappool package provides connection pooling for go-ldap in the same style as Golang's database/sql package. It is designed to be safe for concurrent use by multiple goroutines.

Usage

Installation

go get -u github.com/kolatat/go-ldappool

Connecting

// TODO

Searching

// TODO

Features

  • connecting to multiple servers
  • concurrent use by multiple goroutines
  • support for context.Context (in the pool level but not yet in LDAP) operations
  • server discovery via DNS SRV records (at the pool level, not connection)
Notes, Goals, TODOs
  • very much Active Directory oriented
  • tests
  • preferences towards faster, lower-latency servers
  • AD features not supported by standard LDAP calls
    • password modification

Thanks, sql.DB

In fact, this package is virtually a copy of the database/sql connection pool, with LDAP connections swapped in place of SQL connections and other SQL specifics removed. Many design choices and configuration parameters can be determined by consulting the database/sql documentations.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoServerDefined    = errors.New("ad: no server defined")
	ErrDirClosed          = errors.New("ad: directory closed")
	ErrDuplicateConnClose = errors.New("ad: duplicate conn close")
	ErrConnExpired        = adErr{ErrBadConn, "ad: connection expired"}
	ErrBadConn            = errors.New("ad: bad conn")
)

Functions

func IsBadConn

func IsBadConn(err error) bool

Types

type DBStats

type DBStats = sql.DBStats

type Directory

type Directory struct {
	Name string
	// contains filtered or unexported fields
}

func OpenDirectory

func OpenDirectory(domain string, opt ...*Option) (*Directory, error)

func (*Directory) Del

func (dir *Directory) Del(ctx context.Context, delRequest *ldap.DelRequest) error

func (*Directory) Modify

func (dir *Directory) Modify(ctx context.Context, modifyRequest *ldap.ModifyRequest) error

func (*Directory) ModifyWithResult

func (dir *Directory) ModifyWithResult(ctx context.Context, modifyRequest *ldap.ModifyRequest) (res *ldap.ModifyResult, err error)

func (*Directory) PrintSRVs

func (dir *Directory) PrintSRVs()

func (*Directory) Search

func (dir *Directory) Search(ctx context.Context, searchRequest *ldap.SearchRequest) (res *ldap.SearchResult, err error)

func (*Directory) SearchWithPaging

func (dir *Directory) SearchWithPaging(ctx context.Context, searchRequest *ldap.SearchRequest, pagingSize uint32) (res *ldap.SearchResult, err error)

func (*Directory) SetConnMaxIdleTime

func (dir *Directory) SetConnMaxIdleTime(d time.Duration)

func (*Directory) SetConnMaxLifetime

func (dir *Directory) SetConnMaxLifetime(d time.Duration)

func (*Directory) SetMaxIdleConns

func (dir *Directory) SetMaxIdleConns(n int)

func (*Directory) SetMaxOpenConns

func (dir *Directory) SetMaxOpenConns(n int)

func (*Directory) Stats

func (dir *Directory) Stats() DBStats

func (*Directory) StickyConn

func (dir *Directory) StickyConn(ctx context.Context, fn func(stickyConn *ldap.Conn) error) error

func (*Directory) VerifyPassword

func (dir *Directory) VerifyPassword(ctx context.Context, username, password string) error

type Option

type Option struct {
	StartTLS  bool
	TLSConfig *tls.Config

	// by default the connector will use the scheme (ldap/ldaps) returned by net.LookupSRV.
	// setting LDAPsPort to a non-zero value will force ldaps on all ldap scheme at the specified port
	LDAPsPort uint16

	BindFunc func(ctx context.Context, conn *ldap.Conn, server *Server) error

	Dialer *net.Dialer

	MaxIdleConns    int
	MaxOpenConns    int
	ConnMaxLifetime time.Duration
	ConnMaxIdleTime time.Duration
}

type Server

type Server struct {
	*net.SRV
	Service string
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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