Documentation ¶
Index ¶
- Variables
- func TestConfig(ldapConfig models.LdapConf) (bool, error)
- func UnderBaseDN(baseDN, childDN string) (bool, error)
- type FilterBuilder
- type Manager
- type Session
- func (s *Session) Bind(dn string, password string) error
- func (s *Session) Close()
- func (s *Session) Open() error
- func (s *Session) SearchGroupByDN(groupDN string) ([]model.Group, error)
- func (s *Session) SearchGroupByName(groupName string) ([]model.Group, error)
- func (s *Session) SearchLdap(filter string) (*goldap.SearchResult, error)
- func (s *Session) SearchLdapAttribute(baseDN, filter string, attributes []string) (*goldap.SearchResult, error)
- func (s *Session) SearchUser(username string) ([]model.User, error)
Constants ¶
This section is empty.
Variables ¶
var ErrDNSyntax = errors.New("invalid DN syntax")
ErrDNSyntax ...
var ErrEmptyBaseDN = errors.New("empty base dn")
ErrEmptyBaseDN ...
var ErrEmptyPassword = errors.New("empty password")
ErrEmptyPassword ...
var ErrEmptySearchDN = errors.New("empty search dn")
ErrEmptySearchDN ...
var ErrInvalidCredential = errors.New("invalid credential")
ErrInvalidCredential ...
var ErrInvalidFilter = errors.New("invalid filter syntax")
ErrInvalidFilter ...
var ErrLDAPPingFail = errors.New("fail to ping LDAP server")
ErrLDAPPingFail ...
var ErrLDAPServerTimeout = errors.New("ldap server network timeout")
ErrLDAPServerTimeout ...
var ErrNotFound = errors.New("entity not found")
ErrNotFound ...
var ( // Mgr default quota manager Mgr = New() )
Functions ¶
func TestConfig ¶
TestConfig - test ldap session connection, out of the scope of normal session create/close
func UnderBaseDN ¶
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 ...
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
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session - define a LDAP session
func NewSession ¶
NewSession create session with configs
func (*Session) SearchGroupByDN ¶
SearchGroupByDN ...
func (*Session) SearchGroupByName ¶
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