ldappool

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LDAPConnection

type LDAPConnection interface {
	// SetState sets the current state of the LDAP connection to the specified LDAPState value.
	SetState(state definitions.LDAPState)

	// GetState returns the current state of the LDAP connection as a value of type definitions.LDAPState.
	GetState() definitions.LDAPState

	// SetConn sets the LDAP connection instance to be used for subsequent operations.
	SetConn(*ldap.Conn)

	// GetConn retrieves the current LDAP connection instance, allowing interaction with the LDAP server.
	GetConn() *ldap.Conn

	// GetMutex retrieves the mutex associated with the LDAP connection for synchronization purposes.
	GetMutex() *sync.Mutex

	// Connect establishes an LDAP connection using the provided GUID and configuration, returning an error if it fails.
	Connect(guid *string, ldapConf *config.LDAPConf) error

	// Bind attempts to authenticate and establish a bound state for the LDAP connection using the provided credentials.
	Bind(guid *string, ldapConf *config.LDAPConf) error

	// Unbind gracefully disconnects the LDAP connection by sending an unbind request to the server and returns any error encountered.
	Unbind() error

	// IsClosing checks whether the LDAP connection is in the process of closing and returns true if it is.
	IsClosing() bool

	// Search executes an LDAP search request based on the specified LDAPRequest and returns the results, raw entries, or an error.
	Search(ldapRequest *bktype.LDAPRequest) (bktype.AttributeMapping, []*ldap.Entry, error)

	// ModifyAdd processes an LDAP ModifyAdd request by adding attributes to an entry based on the provided LDAPRequest.
	ModifyAdd(ldapRequest *bktype.LDAPRequest) error
}

LDAPConnection defines behaviors for managing and interacting with an LDAP connection.

type LDAPConnectionImpl

type LDAPConnectionImpl struct {
	// contains filtered or unexported fields
}

LDAPConnectionImpl represents the connection with an LDAP server. It encapsulates the LDAP connection state and provides a means to synchronize access to it.

func (*LDAPConnectionImpl) Bind

func (l *LDAPConnectionImpl) Bind(guid *string, ldapConf *config.LDAPConf) error

Bind establishes a connection to the LDAP server using either SASL External or simple bind based on the configuration provided.

func (*LDAPConnectionImpl) Connect

func (l *LDAPConnectionImpl) Connect(guid *string, ldapConf *config.LDAPConf) error

Connect establishes a connection to the LDAP server using the provided configuration and GUID. It handles TLS setup, retries, connection timeouts, and supports failover across multiple server URIs. Returns an error if the connection could not be established or times out.

func (*LDAPConnectionImpl) GetConn

func (l *LDAPConnectionImpl) GetConn() *ldap.Conn

GetConn retrieves the current LDAP connection instance managed by LDAPConnectionImpl.

func (*LDAPConnectionImpl) GetMutex

func (l *LDAPConnectionImpl) GetMutex() *sync.Mutex

func (*LDAPConnectionImpl) GetState

GetState returns the current state of the LDAP connection as a value of type definitions.LDAPState.

func (*LDAPConnectionImpl) IsClosing

func (l *LDAPConnectionImpl) IsClosing() bool

IsClosing checks if the underlying LDAP connection is in the process of closing. Returns true if closing, false otherwise.

func (*LDAPConnectionImpl) ModifyAdd

func (l *LDAPConnectionImpl) ModifyAdd(ldapRequest *bktype.LDAPRequest) (err error)

ModifyAdd performs an LDAP modify-add operation using the provided LDAPRequest to add attributes to an entry. Returns an error if the operation fails or if the provided search filter yields no results.

func (*LDAPConnectionImpl) Search

func (l *LDAPConnectionImpl) Search(ldapRequest *bktype.LDAPRequest) (result bktype.AttributeMapping, rawResult []*ldap.Entry, err error)

Search performs an LDAP search based on the provided LDAPRequest and returns the corresponding results or an error.

func (*LDAPConnectionImpl) SetConn

func (l *LDAPConnectionImpl) SetConn(conn *ldap.Conn)

SetConn sets the internal LDAP connection instance to the provided *ldap.Conn.

func (*LDAPConnectionImpl) SetState

func (l *LDAPConnectionImpl) SetState(state definitions.LDAPState)

SetState updates the current state of the LDAPConnectionImpl to the provided LDAPState value.

func (*LDAPConnectionImpl) Unbind

func (l *LDAPConnectionImpl) Unbind() (err error)

Unbind closes the LDAP connection and unbinds from the server.

type LDAPPool

type LDAPPool interface {
	// StartHouseKeeper starts a background process for resource management and cleanup within the LDAP pool.
	StartHouseKeeper()

	// SetIdleConnections configures and manages idle connections in the pool based on the provided bind parameter.
	SetIdleConnections(bind bool) error

	// HandleLookupRequest handles an LDAP lookup request and utilizes a WaitGroup for managing concurrency.
	HandleLookupRequest(ldapRequest *bktype.LDAPRequest, ldapWaitGroup *sync.WaitGroup) error

	// HandleAuthRequest processes an LDAP authentication request and manages concurrency using a WaitGroup.
	HandleAuthRequest(ldapAuthRequest *bktype.LDAPAuthRequest, ldapWaitGroup *sync.WaitGroup) error

	// Close releases all resources used by the LDAPPool and terminates any background processes or connections.
	Close()
}

LDAPPool is an interface that represents a pool for managing LDAP connections and operations efficiently.

func NewPool

func NewPool(ctx context.Context, poolType int, poolName string) LDAPPool

NewPool creates and initializes a new LDAPPool based on the specified pool type and context for LDAP operations.

Jump to

Keyboard shortcuts

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