ldap

package
v0.0.0-...-a548ab7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDNSyntax = errors.New("invalid DN syntax")

ErrDNSyntax ...

View Source
var ErrEmptyBaseDN = errors.New("empty base dn")

ErrEmptyBaseDN ...

View Source
var ErrEmptyPassword = errors.New("empty password")

ErrEmptyPassword ...

View Source
var ErrEmptySearchDN = errors.New("empty search dn")

ErrEmptySearchDN ...

View Source
var ErrInvalidCredential = errors.New("invalid credential")

ErrInvalidCredential ...

View Source
var ErrInvalidFilter = errors.New("invalid filter syntax")

ErrInvalidFilter ...

View Source
var ErrLDAPPingFail = errors.New("fail to ping LDAP server")

ErrLDAPPingFail ...

View Source
var ErrLDAPServerTimeout = errors.New("ldap server network timeout")

ErrLDAPServerTimeout ...

View Source
var ErrNotFound = errors.New("entity not found")

ErrNotFound ...

View Source
var (
	// Mgr default quota manager
	Mgr = New()
)

Functions

func TestConfig

func TestConfig(ldapConfig models.LdapConf) (bool, error)

TestConfig - test ldap session connection, out of the scope of normal session create/close

func UnderBaseDN

func UnderBaseDN(baseDN, childDN string) (bool, error)

UnderBaseDN - check if the childDN is under the baseDN, if the baseDN equals current DN, return true

Types

type FilterBuilder

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

FilterBuilder build filter for ldap search

func NewFilterBuilder

func NewFilterBuilder(filter string) (*FilterBuilder, error)

NewFilterBuilder parse FilterBuilder from string

func (*FilterBuilder) And

func (f *FilterBuilder) And(filterB *FilterBuilder) *FilterBuilder

And ...

func (*FilterBuilder) Or

func (f *FilterBuilder) Or(filterB *FilterBuilder) *FilterBuilder

Or ...

func (*FilterBuilder) String

func (f *FilterBuilder) String() (string, error)

String ...

type Manager

type Manager interface {
	// Ping ldap test
	Ping(ctx context.Context, cfg cfgModels.LdapConf) (bool, error)
	SearchUser(ctx context.Context, sess *Session, username string) ([]model.User, error)
	ImportUser(ctx context.Context, sess *Session, ldapImportUsers []string) ([]model.FailedImportUser, error)
	SearchGroup(ctx context.Context, sess *Session, groupName, groupDN string) ([]model.Group, error)
}

Manager is used for ldap management

func New

func New() Manager

New returns a default implementation of Manager

type Session

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

Session - define a LDAP session

func NewSession

func NewSession(basicCfg models.LdapConf, groupCfg models.GroupConf) *Session

NewSession create session with configs

func (*Session) Bind

func (s *Session) Bind(dn string, password string) error

Bind with specified DN and password, used in authentication

func (*Session) Close

func (s *Session) Close()

Close - close current session

func (*Session) Open

func (s *Session) Open() error

Open - open Session, should invoke Close for each Open call

func (*Session) SearchGroupByDN

func (s *Session) SearchGroupByDN(groupDN string) ([]model.Group, error)

SearchGroupByDN ...

func (*Session) SearchGroupByName

func (s *Session) SearchGroupByName(groupName string) ([]model.Group, error)

SearchGroupByName ...

func (*Session) SearchLdap

func (s *Session) SearchLdap(filter string) (*goldap.SearchResult, error)

SearchLdap to search ldap with the provide filter

func (*Session) SearchLdapAttribute

func (s *Session) SearchLdapAttribute(baseDN, filter string, attributes []string) (*goldap.SearchResult, error)

SearchLdapAttribute - to search ldap with the provide filter, with specified attributes

func (*Session) SearchUser

func (s *Session) SearchUser(username string) ([]model.User, error)

SearchUser - search LDAP user by name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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