ldapbuilder

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDBDriver

func BuildDBDriver(opts *Options) string

BuildDBDriver return a driver like "protocol://host:port"

func WithBaseDN

func WithBaseDN[T IBaseDN](baseDN string) func(T)

func WithControls

func WithControls[T IControls](controls []ldap.Control) func(T)

Types

type AddOption

type AddOption func(opts *AddOptions)

type AddOptions

type AddOptions struct {
	*BaseOptions
	*ldap.AddRequest
}

type BaseOption

type BaseOption func(opt *BaseOptions)

type BaseOptions

type BaseOptions struct {
	BaseDN   string
	Controls []ldap.Control
}

type DBConnect

type DBConnect struct {
	*ldap.Conn
	Options *Options
}

func New

func New(opts ...Option) (*DBConnect, error)

func (*DBConnect) DoAdd

func (db *DBConnect) DoAdd(ctx context.Context, opts ...AddOption) error

DoAdd 执行默认 ldap 查询

AddOptions:
WithBaseDN[*RequestOptions]   默认为创建连接时的 DN,如果创建连接时未指定,则这里必须指定
WithControls[*RequestOptions]
db.WithAttribute
db.WithAddAttributes

func (*DBConnect) DoDel

func (db *DBConnect) DoDel(ctx context.Context, opts ...DelOption) error

DoAdd 执行默认 ldap 查询

AddOptions:
WithBaseDN[*RequestOptions]   默认为创建连接时的 DN,如果创建连接时未指定,则这里必须指定
WithControls[*RequestOptions]

func (*DBConnect) DoModify

func (db *DBConnect) DoModify(ctx context.Context, opts ...ModifyOption) (*ldap.ModifyResult, error)

DoModify 执行默认 ldap 查询

ModifyOptions:
WithBaseDN[*RequestOptions]   默认为创建连接时的 DN,如果创建连接时未指定,则这里必须指定
WithControls[*RequestOptions]
db.WithAdd
db.WithDelete
db.WithReplace
db.WithIncrement
db.WithChanges

func (*DBConnect) DoModifyDN

func (db *DBConnect) DoModifyDN(ctx context.Context, opts ...ModifyDNOption) error

DoModifyDN 执行默认 ldap 查询

ModifyDNOptions:
WithBaseDN[*RequestOptions]   默认为创建连接时的 DN,如果创建连接时未指定,则这里必须指定
WithControls[*RequestOptions]
db.WithNewRDN
db.WithDeleteOldRDN
db.WithNewSuperior

func (*DBConnect) DoPasswordModify

func (db *DBConnect) DoPasswordModify(ctx context.Context, opts ...PasswordModifyOption) (*ldap.PasswordModifyResult, error)

DoPasswordModify 执行默认 ldap 查询

PasswordModifyOptions:
db.WithUserIdentity 必须
db.WithOldPassword  必须
db.WithNewPassword  必须

func (*DBConnect) DoSearch

func (db *DBConnect) DoSearch(ctx context.Context, filter string, opts ...RequestOption) (results []*ldap.Entry, err error)

DoSearch 执行默认 ldap 查询

ReuqestOptions:
WithBaseDN[*RequestOptions]   默认为创建连接时的 DN,如果创建连接时未指定,则这里必须指定
WithControls[*RequestOptions]
db.WithSearchAttributes       默认查询全部字段
db.WithScope
db.WithDerefAliases
db.WithSizeLimit
db.WithTimeLimit
db.WithTypesOnly
db.WithPageSize

func (*DBConnect) WithAdd

func (db *DBConnect) WithAdd(attrType string, attrVals []string) ModifyOption

func (*DBConnect) WithAddAttributes

func (db *DBConnect) WithAddAttributes(attrs []ldap.Attribute) AddOption

func (*DBConnect) WithAttribute

func (db *DBConnect) WithAttribute(attrType string, attrVals []string) AddOption

func (*DBConnect) WithChanges

func (db *DBConnect) WithChanges(changes []ldap.Change) ModifyOption

func (*DBConnect) WithDelete

func (db *DBConnect) WithDelete(attrType string, attrVals []string) ModifyOption

func (*DBConnect) WithDeleteOldRDN

func (db *DBConnect) WithDeleteOldRDN(delOld bool) ModifyDNOption

func (*DBConnect) WithDerefAliases

func (db *DBConnect) WithDerefAliases(derefAliases int) RequestOption

func (*DBConnect) WithFilter

func (db *DBConnect) WithFilter(filter string) RequestOption

func (*DBConnect) WithIncrement

func (db *DBConnect) WithIncrement(attrType string, attrVals string) ModifyOption

func (*DBConnect) WithNewPassword

func (db *DBConnect) WithNewPassword(newPassword string) PasswordModifyOption

func (*DBConnect) WithNewRDN

func (db *DBConnect) WithNewRDN(rdn string) ModifyDNOption

func (*DBConnect) WithNewSuperior

func (db *DBConnect) WithNewSuperior(newSup string) ModifyDNOption

func (*DBConnect) WithOldPassword

func (db *DBConnect) WithOldPassword(oldPassword string) PasswordModifyOption

func (*DBConnect) WithPageSize

func (db *DBConnect) WithPageSize(pageSize uint32) RequestOption

func (*DBConnect) WithReplace

func (db *DBConnect) WithReplace(attrType string, attrVals []string) ModifyOption

func (*DBConnect) WithScope

func (db *DBConnect) WithScope(scope int) RequestOption

func (*DBConnect) WithSearchAttributes

func (db *DBConnect) WithSearchAttributes(attributes []string) RequestOption

func (*DBConnect) WithSizeLimit

func (db *DBConnect) WithSizeLimit(sizeLimit int) RequestOption

func (*DBConnect) WithTimeLimit

func (db *DBConnect) WithTimeLimit(timeLimit int) RequestOption

func (*DBConnect) WithTypesOnly

func (db *DBConnect) WithTypesOnly(typesOnly bool) RequestOption

func (*DBConnect) WithUserIdentity

func (db *DBConnect) WithUserIdentity(userIdentity string) PasswordModifyOption

type DelOption

type DelOption func(*DelOptions)

type DelOptions

type DelOptions struct {
	*BaseOptions
	*ldap.DelRequest
}

type IBaseDN

type IBaseDN interface {
	// contains filtered or unexported methods
}

type IControls

type IControls interface {
	// contains filtered or unexported methods
}

type ModifyDNOption

type ModifyDNOption func(opts *ModifyDNOptions)

type ModifyDNOptions

type ModifyDNOptions struct {
	*BaseOptions
	*ldap.ModifyDNRequest
}

type ModifyOption

type ModifyOption func(opts *ModifyOptions)

type ModifyOptions

type ModifyOptions struct {
	*BaseOptions
	*ldap.ModifyRequest
}

type Option

type Option func(opts *Options)

func WithHost

func WithHost(host string) Option

WithHost eg: 127.0.0.1

func WithPass

func WithPass(pass string) Option

func WithPort

func WithPort(port int) Option

func WithProtocol

func WithProtocol(protocol string) Option

WithProtocol eg: ldap

func WithTLS

func WithTLS(tls bool) Option

func WithUser

func WithUser(user string) Option

WithUser eg: administrator@test.com

type Options

type Options struct {
	Protocol string // ldap
	User     string
	Pass     string
	Host     string
	Port     int  // 389
	TLS      bool // false
	*BaseOptions
}

type PasswordModifyOption

type PasswordModifyOption func(opts *PasswordModifyOptions)

type PasswordModifyOptions

type PasswordModifyOptions struct {
	*ldap.PasswordModifyRequest
}

type RequestOption

type RequestOption func(opts *RequestOptions)

type RequestOptions

type RequestOptions struct {
	PageSize uint32
	*BaseOptions
	*ldap.SearchRequest
}

Jump to

Keyboard shortcuts

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