ldap

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("pool is closed")

ErrClosed is the error resulting if the pool is closed via pool.Close().

Functions

func GetAvailableObjectClass

func GetAvailableObjectClass(clt ldap.Client) (sets.Set[string], error)

func IsLdapError

func IsLdapError(err error, errCode ...uint16) bool

func WithConnContext

func WithConnContext(ctx context.Context, client ldap.Client) context.Context

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, o *LdapOptions) (*Client, error)

func (Client) Close

func (l Client) Close()

func (Client) Marshal

func (l Client) Marshal() ([]byte, error)

func (Client) MarshalJSON

func (l Client) MarshalJSON() ([]byte, error)

func (*Client) Merge

func (l *Client) Merge(src proto.Message)

Merge implement proto.Merger

func (*Client) Options

func (l *Client) Options() *LdapOptions

func (*Client) ProtoMessage

func (l *Client) ProtoMessage()

ProtoMessage implement proto.Message

func (*Client) Reset

func (l *Client) Reset()

Reset *implement proto.Message*

func (*Client) Session

func (l *Client) Session(ctx context.Context) ldap.Client

func (Client) String

func (l Client) String() string

String implement proto.Message

func (*Client) Unmarshal

func (l *Client) Unmarshal(data []byte) (err error)

func (*Client) UnmarshalJSON

func (l *Client) UnmarshalJSON(data []byte) (err error)

type LdapOptions

type LdapOptions struct {
	Host                 string                                              `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
	ManagerDn            string                                              `protobuf:"bytes,2,opt,name=manager_dn,json=managerDn,proto3" json:"manager_dn,omitempty"`
	ManagerPassword      *github_com_MicroOps_cn_fuck_safe.String            `` /* 157-byte string literal not displayed */
	UserSearchBase       string                                              `protobuf:"bytes,4,opt,name=user_search_base,json=userSearchBase,proto3" json:"user_search_base,omitempty"`
	UserSearchFilter     string                                              `protobuf:"bytes,5,opt,name=user_search_filter,json=userSearchFilter,proto3" json:"user_search_filter,omitempty"`
	AppSearchBase        string                                              `protobuf:"bytes,6,opt,name=app_search_base,json=appSearchBase,proto3" json:"app_search_base,omitempty"`
	AppSearchFilter      string                                              `protobuf:"bytes,7,opt,name=app_search_filter,json=appSearchFilter,proto3" json:"app_search_filter,omitempty"`
	AppObjectClass       string                                              `protobuf:"bytes,8,opt,name=app_object_class,json=appObjectClass,proto3" json:"app_object_class,omitempty"`
	AttrUsername         string                                              `protobuf:"bytes,9,opt,name=attr_username,json=attrUsername,proto3" json:"attr_username,omitempty"`
	AttrEmail            string                                              `protobuf:"bytes,10,opt,name=attr_email,json=attrEmail,proto3" json:"attr_email,omitempty"`
	AttrUserDisplayName  string                                              `protobuf:"bytes,11,opt,name=attr_user_display_name,json=attrUserDisplayName,proto3" json:"attr_user_display_name,omitempty"`
	AttrUserPhoneNo      string                                              `protobuf:"bytes,12,opt,name=attr_user_phone_no,json=attrUserPhoneNo,proto3" json:"attr_user_phone_no,omitempty"`
	IsTLS                bool                                                `protobuf:"varint,13,opt,name=is_tls,json=isTls,proto3" json:"is_tls,omitempty"`
	StartTLS             bool                                                `protobuf:"varint,14,opt,name=start_tls,json=startTls,proto3" json:"start_tls,omitempty"`
	TLS                  *github_com_MicroOps_cn_fuck_clients_tls.TLSOptions `protobuf:"bytes,15,opt,name=tls,proto3,customtype=github.com/MicroOps-cn/fuck/clients/tls.TLSOptions" json:"tls,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                                            `json:"-"`
	XXX_unrecognized     []byte                                              `json:"-"`
	XXX_sizecache        int32                                               `json:"-"`
}

func NewLdapOptions

func NewLdapOptions() *LdapOptions

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

func (*LdapOptions) Descriptor

func (*LdapOptions) Descriptor() ([]byte, []int)

func (*LdapOptions) GetAppObjectClass

func (m *LdapOptions) GetAppObjectClass() string

func (*LdapOptions) GetAppSearchBase

func (m *LdapOptions) GetAppSearchBase() string

func (*LdapOptions) GetAppSearchFilter

func (m *LdapOptions) GetAppSearchFilter() string

func (*LdapOptions) GetAttrEmail

func (m *LdapOptions) GetAttrEmail() string

func (*LdapOptions) GetAttrUserDisplayName

func (m *LdapOptions) GetAttrUserDisplayName() string

func (*LdapOptions) GetAttrUserPhoneNo

func (m *LdapOptions) GetAttrUserPhoneNo() string

func (*LdapOptions) GetAttrUsername

func (m *LdapOptions) GetAttrUsername() string

func (*LdapOptions) GetHost

func (m *LdapOptions) GetHost() string

func (*LdapOptions) GetIsTLS

func (m *LdapOptions) GetIsTLS() bool

func (*LdapOptions) GetManagerDn

func (m *LdapOptions) GetManagerDn() string

func (*LdapOptions) GetStartTLS

func (m *LdapOptions) GetStartTLS() bool

func (*LdapOptions) GetUserSearchBase

func (m *LdapOptions) GetUserSearchBase() string

func (*LdapOptions) GetUserSearchFilter

func (m *LdapOptions) GetUserSearchFilter() string

func (*LdapOptions) ParseUserSearchFilter

func (x *LdapOptions) ParseUserSearchFilter(username ...string) string

func (*LdapOptions) ProtoMessage

func (*LdapOptions) ProtoMessage()

func (*LdapOptions) Reset

func (m *LdapOptions) Reset()

func (*LdapOptions) String

func (m *LdapOptions) String() string

func (*LdapOptions) UnmarshalJSONPB

func (x *LdapOptions) UnmarshalJSONPB(unmarshaller *jsonpb.Unmarshaler, b []byte) error

func (*LdapOptions) Valid

func (x *LdapOptions) Valid() error

func (*LdapOptions) XXX_DiscardUnknown

func (m *LdapOptions) XXX_DiscardUnknown()

func (*LdapOptions) XXX_Marshal

func (m *LdapOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LdapOptions) XXX_Merge

func (m *LdapOptions) XXX_Merge(src proto.Message)

func (*LdapOptions) XXX_Size

func (m *LdapOptions) XXX_Size() int

func (*LdapOptions) XXX_Unmarshal

func (m *LdapOptions) XXX_Unmarshal(b []byte) error

type NopCloser

type NopCloser struct {
	ldap.Client
}

func (NopCloser) Close

func (NopCloser) Close()

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.

func NewChannelPool

func NewChannelPool(ctx context.Context, initialCap, maxCap int, name string, factory PoolFactory, closeAt []uint16) (Pool, error)

NewChannelPool returns a new pool based on buffered channels with an initial capacity and maximum capacity. Factory is used when initial capacity is greater than zero to fill the pool. A zero initialCap doesn't fill the Pool until a new Get() is called. During a Get(), If there is no new connection available in the pool, a new connection will be created via the Factory() method.

closeAt will automagically mark the connection as unusable if the return code of the call is one of those passed, most likely you want to set this to something like []uint8{ldap.LDAPResultTimeLimitExceeded, ldap.ErrorNetwork}

func NewLdapPool

func NewLdapPool(ctx context.Context, options *LdapOptions) (pool Pool, err error)

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) ExternalBind

func (p *PoolConn) ExternalBind() error

func (*PoolConn) IsClosing

func (p *PoolConn) IsClosing() bool

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) ModifyWithResult

func (p *PoolConn) ModifyWithResult(request *ldap.ModifyRequest) (*ldap.ModifyResult, error)

func (*PoolConn) NTLMUnauthenticatedBind

func (p *PoolConn) NTLMUnauthenticatedBind(domain, username string) 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

func (*PoolConn) TLSConnectionState

func (p *PoolConn) TLSConnectionState() (tls.ConnectionState, bool)

func (*PoolConn) UnauthenticatedBind

func (p *PoolConn) UnauthenticatedBind(username string) error

func (*PoolConn) Unbind

func (p *PoolConn) Unbind() error

type PoolFactory

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

PoolFactory is a function to create new connections.

type Session

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

func (*Session) Add

func (s *Session) Add(addRequest *ldap.AddRequest) (err error)

func (*Session) Bind

func (s *Session) Bind(username, password string) (err error)

func (*Session) Close

func (s *Session) Close()

func (*Session) Compare

func (s *Session) Compare(dn, attribute, value string) (bool, error)

func (*Session) Del

func (s *Session) Del(delRequest *ldap.DelRequest) (err error)

func (*Session) Error

func (s *Session) Error() error

func (*Session) ExternalBind

func (s *Session) ExternalBind() error

func (*Session) IsClosing

func (s *Session) IsClosing() bool

func (*Session) Modify

func (s *Session) Modify(modifyRequest *ldap.ModifyRequest) (err error)

func (*Session) ModifyDN

func (s *Session) ModifyDN(modifyDNRequest *ldap.ModifyDNRequest) (err error)

func (*Session) ModifyWithResult

func (s *Session) ModifyWithResult(request *ldap.ModifyRequest) (*ldap.ModifyResult, error)

func (*Session) NTLMUnauthenticatedBind

func (s *Session) NTLMUnauthenticatedBind(domain, username string) error

func (*Session) PasswordModify

func (s *Session) PasswordModify(passwordModifyRequest *ldap.PasswordModifyRequest) (ret *ldap.PasswordModifyResult, err error)

func (*Session) Search

func (s *Session) Search(searchRequest *ldap.SearchRequest) (result *ldap.SearchResult, err error)

func (*Session) SearchWithPaging

func (s *Session) SearchWithPaging(searchRequest *ldap.SearchRequest, pagingSize uint32) (ret *ldap.SearchResult, err error)

func (*Session) SetTimeout

func (s *Session) SetTimeout(duration time.Duration)

func (*Session) SimpleBind

func (s *Session) SimpleBind(simpleBindRequest *ldap.SimpleBindRequest) (ret *ldap.SimpleBindResult, err error)

func (*Session) Start

func (s *Session) Start()

func (*Session) StartTLS

func (s *Session) StartTLS(config *tls.Config) error

func (*Session) TLSConnectionState

func (s *Session) TLSConnectionState() (tls.ConnectionState, bool)

func (*Session) UnauthenticatedBind

func (s *Session) UnauthenticatedBind(username string) error

func (*Session) Unbind

func (s *Session) Unbind() error

Jump to

Keyboard shortcuts

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