ldapserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0, BSD-3-Clause Imports: 10 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             = 0
	FilterOr              = 1
	FilterNot             = 2
	FilterEqualityMatch   = 3
	FilterSubstrings      = 4
	FilterGreaterOrEqual  = 5
	FilterLessOrEqual     = 6
	FilterPresent         = 7
	FilterApproxMatch     = 8
	FilterExtensibleMatch = 9
)
View Source
const (
	FilterSubstringsInitial = 0
	FilterSubstringsAny     = 1
	FilterSubstringsFinal   = 2
)
View Source
const (
	LDAPBindAuthSimple = 0
	LDAPBindAuthSASL   = 3
)

Variables

View Source
var FilterMap = map[uint8]string{
	FilterAnd:             "And",
	FilterOr:              "Or",
	FilterNot:             "Not",
	FilterEqualityMatch:   "Equality Match",
	FilterSubstrings:      "Substrings",
	FilterGreaterOrEqual:  "Greater Or Equal",
	FilterLessOrEqual:     "Less Or Equal",
	FilterPresent:         "Present",
	FilterApproxMatch:     "Approx Match",
	FilterExtensibleMatch: "Extensible Match",
}

Functions

func CompileFilter

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

func DecompileFilter

func DecompileFilter(packet *ber.Packet) (ret string, err 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)

Types

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 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 Searcher

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

type Server

type Server struct {
	BindFns     map[string]Binder
	SearchFns   map[string]Searcher
	CloseFns    map[string]Closer
	Quit        chan bool
	EnforceLDAP bool
	Stats       *Stats
}

func NewServer

func NewServer() *Server

func (*Server) BindFunc

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

func (*Server) CloseFunc

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

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