ldapserver

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, BSD-3-Clause Imports: 15 Imported by: 0

README

LDAP server library for Golang

This library provides LDAP server v3 functionality for the GO programming language.

The server implementation is based on github.com/nmcclain/ldap and is enhanced so it can be used together with github.com/go-ldap/ldap/v3.

From the server perspective, all of RFC4510 is implemented except:

4.5.1.3. SearchRequest.derefAliases 4.5.1.5. SearchRequest.timeLimit 4.5.1.6. SearchRequest.typesOnly 4.14. StartTLS Operation

The purpose of this library is not a general LDAP server implementation but to provide enough of an LDAP server for Kopano compatible identity management.

License

See LICENSE.txt for licensing information of this module.

Documentation

Index

Constants

View Source
const (
	FilterAnd             = ldap.FilterAnd
	FilterOr              = ldap.FilterOr
	FilterNot             = ldap.FilterNot
	FilterEqualityMatch   = ldap.FilterEqualityMatch
	FilterSubstrings      = ldap.FilterSubstrings
	FilterGreaterOrEqual  = ldap.FilterGreaterOrEqual
	FilterLessOrEqual     = ldap.FilterLessOrEqual
	FilterPresent         = ldap.FilterPresent
	FilterApproxMatch     = ldap.FilterApproxMatch
	FilterExtensibleMatch = ldap.FilterExtensibleMatch
)
View Source
const (
	FilterSubstringsInitial = ldap.FilterSubstringsInitial
	FilterSubstringsAny     = ldap.FilterSubstringsAny
	FilterSubstringsFinal   = ldap.FilterSubstringsFinal
)
View Source
const (
	LDAPBindAuthSimple = 0
	LDAPBindAuthSASL   = 3
)
View Source
const (
	TagReqIdentity = 0
	TagReqOldPW    = 1
	TagReqNewPW    = 2
	TagRespGenPW   = 0
)

Variables

View Source
var (
	FilterMap = ldap.FilterMap
)

Functions

func CompileFilter

func CompileFilter(filter string) (*ber.Packet, error)

func DecompileFilter

func DecompileFilter(packet *ber.Packet) (ret string, err error)

func HandleAddRequest added in v0.4.0

func HandleAddRequest(req *ber.Packet, boundDN string, server *Server, conn net.Conn) error

func HandleDeleteRequest added in v0.4.0

func HandleDeleteRequest(req *ber.Packet, boundDN string, server *Server, conn net.Conn) error

func HandleExtendedRequest added in v0.4.0

func HandleExtendedRequest(req *ber.Packet, boundDN string, server *Server, conn net.Conn) (*ber.Packet, error)

func HandleModifyDNRequest added in v0.5.0

func HandleModifyDNRequest(req *ber.Packet, boundDN string, server *Server, conn net.Conn) error

func HandleModifyRequest added in v0.4.0

func HandleModifyRequest(req *ber.Packet, boundDN string, server *Server, conn net.Conn) error

func HandlePasswordModifyExOp added in v0.4.0

func HandlePasswordModifyExOp(req *ber.Packet, boundDN string, server *Server, conn net.Conn) (*ber.Packet, error)

func HandleSearchRequest

func HandleSearchRequest(req *ber.Packet, controls *[]ldap.Control, messageID int64, boundDN string, server *Server, conn net.Conn) (doneControls *[]ldap.Control, resultErr error)

func Logger added in v0.4.0

func Logger(l logr.Logger)

func RegisterExtendedOperation added in v0.4.0

func RegisterExtendedOperation(oid string, handler ExopHandler)

Types

type Adder added in v0.4.0

type Adder interface {
	Add(boundDN string, req *ldap.AddRequest, conn net.Conn) (LDAPResultCode, error)
}

type Binder

type Binder interface {
	Bind(bindDN, bindSimplePw string, conn net.Conn) (LDAPResultCode, error)
}

type Closer

type Closer interface {
	Close(boundDN string, conn net.Conn) error
}

type Deleter added in v0.4.0

type Deleter interface {
	Delete(boundDN string, req *ldap.DelRequest, conn net.Conn) (LDAPResultCode, error)
}

type ExopHandler added in v0.4.0

type ExopHandler func(req *ber.Packet, boundDN string, server *Server, conn net.Conn) (*ber.Packet, error)

type ExtendedRequest added in v0.4.0

type ExtendedRequest struct {
	OID  string
	Body *ber.Packet
}

type LDAPResultCode

type LDAPResultCode uint8

func HandleBindRequest

func HandleBindRequest(req *ber.Packet, fns map[string]Binder, conn net.Conn) (resultCode LDAPResultCode)

func ServerApplyFilter

func ServerApplyFilter(f *ber.Packet, entry *ldap.Entry) (bool, LDAPResultCode)

func ServerFilterAttributes

func ServerFilterAttributes(attributes []string, entry *ldap.Entry) (LDAPResultCode, error)

func ServerFilterScope

func ServerFilterScope(baseDN string, scope int, entry *ldap.Entry) (bool, LDAPResultCode)

type Modifier added in v0.4.0

type Modifier interface {
	Modify(boundDN string, req *ldap.ModifyRequest, conn net.Conn) (LDAPResultCode, error)
}

type PasswordUpdater added in v0.4.0

type PasswordUpdater interface {
	ModifyPasswordExop(boundDN string, req *ldap.PasswordModifyRequest, conn net.Conn) (LDAPResultCode, error)
}

type Renamer added in v0.5.0

type Renamer interface {
	ModifyDN(boundDN string, req *ldap.ModifyDNRequest, conn net.Conn) (LDAPResultCode, error)
}

type Searcher

type Searcher interface {
	Search(boundDN string, req *ldap.SearchRequest, conn net.Conn) (ServerSearchResult, error)
}

type Server

type Server struct {
	AddFns                  map[string]Adder
	BindFns                 map[string]Binder
	DeleteFns               map[string]Deleter
	ModifyFns               map[string]Modifier
	ModifyDNFns             map[string]Renamer
	PasswordExOpFns         map[string]PasswordUpdater
	SearchFns               map[string]Searcher
	CloseFns                map[string]Closer
	Quit                    chan bool
	EnforceLDAP             bool
	GeneratedPasswordLength int
	Stats                   *Stats
}

func NewServer

func NewServer() *Server

func (*Server) AddFunc added in v0.4.0

func (server *Server) AddFunc(baseDN string, f Adder)

func (*Server) BindFunc

func (server *Server) BindFunc(baseDN string, f Binder)

func (*Server) CloseFunc

func (server *Server) CloseFunc(baseDN string, f Closer)

func (*Server) DeleteFunc added in v0.4.0

func (server *Server) DeleteFunc(baseDN string, f Deleter)

func (*Server) GetStats

func (server *Server) GetStats() Stats

func (*Server) ListenAndServe

func (server *Server) ListenAndServe(listenString string) error

func (*Server) ListenAndServeTLS

func (server *Server) ListenAndServeTLS(listenString string, certFile string, keyFile string) error

func (*Server) ModifyDNFunc added in v0.5.0

func (server *Server) ModifyDNFunc(baseDN string, f Renamer)

func (*Server) ModifyFunc added in v0.4.0

func (server *Server) ModifyFunc(baseDN string, f Modifier)

func (*Server) PasswordExOpFunc added in v0.4.0

func (server *Server) PasswordExOpFunc(baseDN string, f PasswordUpdater)

func (*Server) QuitChannel

func (server *Server) QuitChannel(quit chan bool)

func (*Server) SearchFunc

func (server *Server) SearchFunc(baseDN string, f Searcher)

func (*Server) Serve

func (server *Server) Serve(ln net.Listener) error

func (*Server) SetStats

func (server *Server) SetStats(enable bool)

type ServerSearchResult

type ServerSearchResult struct {
	Entries    []*ldap.Entry
	Referrals  []string
	Controls   []ldap.Control
	ResultCode LDAPResultCode
}

type Stats

type Stats struct {
	Conns        uint64
	ConnsCurrent uint64
	ConnsMax     uint64
	Adds         uint64
	Binds        uint64
	Deletes      uint64
	ModifyDNs    uint64
	Modifies     uint64
	Unbinds      uint64
	Searches     uint64
	// contains filtered or unexported fields
}

func (*Stats) Clone

func (stats *Stats) Clone() *Stats

Jump to

Keyboard shortcuts

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