ldsview

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const LDAPMaxLineSize int = 1024 * 1024 * 10

Variables

Functions

func ADIntervalToDays

func ADIntervalToDays(intervalStr string) int

func ADIntervalToMins

func ADIntervalToMins(intervalStr string) int

func BuildAttributeFilter

func BuildAttributeFilter(filterParts []string) internal.HashSetStr

func BuildTitleLine

func BuildTitleLine(entity Entity) (string, error)

func EnableLogging

func EnableLogging()

EnableLogging turns on package logging

func GetFlagsFromUAC

func GetFlagsFromUAC(uac int64) ([]string, error)

GetFlagsFromUAC wraps teh msldapuac dependency for easy re-definition

func GetStructure

func GetStructure(source *LdifParser) ([]string, error)

func GetValues added in v0.3.0

func GetValues(source *LdifParser, attrName string) ([]string, error)

func MatchesFilter

func MatchesFilter(entity Entity, filterConditions []IEntityFilter) bool

MatchesFilter Returns false if an entity fails to match a provided filter. If no filter is specified, will always return true.

func TimeFromADGeneralizedTime

func TimeFromADGeneralizedTime(adTime string) (time.Time, error)

func TimeFromADTimestamp

func TimeFromADTimestamp(adTime string) time.Time

func UACParse

func UACParse(uacValue string) (flagNames []string, err error)

UACParse take a UAC int and return

func UACPrint

func UACPrint(dest io.Writer)

UACPrint prints the available UAC options that are available for searching

Types

type Entity

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

func BuildEntity

func BuildEntity(entityLines []string) Entity

BuildEntity is a wrapper for BuildEntityFromAttrList that doesn't require an attribute filter and returns all entities.

func BuildEntityFromAttrList

func BuildEntityFromAttrList(entityLines []string, includeAttrs *internal.HashSetStr) Entity

BuildEntityFromAttrList will construct an Entity from a list of attribute strings and filter out all attributes not in `includeAttrs`. Either a null or empty HashSetStr value in `includeAttrs` will include all attributes. The `includeAttrs` argument must contain lowercase string values.

func NewEntity

func NewEntity() Entity

func UACSearch

func UACSearch(entities *[]Entity, uacProp int) (matches []Entity)

UACSearch will seek for entities who have the given UAC property set

func (*Entity) AddAttribute

func (e *Entity) AddAttribute(attr EntityAttribute)

func (*Entity) DeocdeTimestamps

func (e *Entity) DeocdeTimestamps()

func (Entity) GetAllAttributeNames

func (e Entity) GetAllAttributeNames() []string

func (Entity) GetAllAttributes

func (e Entity) GetAllAttributes() []EntityAttribute

func (Entity) GetAttribute

func (e Entity) GetAttribute(name string) (EntityAttribute, bool)

func (Entity) GetDN

func (e Entity) GetDN() (EntityAttribute, bool)

func (Entity) Groups

func (e Entity) Groups() []string

func (Entity) IsEmpty

func (e Entity) IsEmpty() bool

func (*Entity) SetAttribute

func (e *Entity) SetAttribute(attr EntityAttribute)

func (Entity) Size

func (e Entity) Size() int

type EntityAttribute

type EntityAttribute struct {
	Name  string
	Value internal.HashSetStr
}

func BuildAttributeFromLine

func BuildAttributeFromLine(attrLine string) (EntityAttribute, error)

func BuildEntityAttribute

func BuildEntityAttribute(name string, initValue string) EntityAttribute

func NewEntityAttribute

func NewEntityAttribute(name string, value string) EntityAttribute

func (EntityAttribute) HasValue

func (attr EntityAttribute) HasValue(val string) bool

func (*EntityAttribute) SetValue

func (attr *EntityAttribute) SetValue(vals ...string)

func (EntityAttribute) Stringify

func (attr EntityAttribute) Stringify() []string

type EntityFilter

type EntityFilter struct {
	AttributeName string
	Value         string
	Condition     FilterCondition
	IsWildcard    bool
}

func (EntityFilter) Matches

func (filter EntityFilter) Matches(entity Entity) bool

type EntitySource

type EntitySource interface {
	BuildEntity(keyAttrName string, keyAttrVal string) (Entity, error)
	BuildEntities() ([]Entity, error)

	SetEntityFilter(filter []IEntityFilter)
	SetAttributeFilter(includeAttrs internal.HashSetStr)
}

EntitySource returns LDAP Entites constructed from an input data source. If filter values are not set, they will default to empty lists. Null values will cause a panic.

type FilterCondition

type FilterCondition string
const (
	FILTER_EQUALS       FilterCondition = ":="
	FILTER_NOT_EQUALS   FilterCondition = ":!="
	FILTER_CONTAINS     FilterCondition = ":~"
	FILTER_NOT_CONTAINS FilterCondition = ":!~"
)

type HailmaryFilter

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

func NewHailmaryFilter

func NewHailmaryFilter(searchTerm string) HailmaryFilter

func (HailmaryFilter) Matches

func (filter HailmaryFilter) Matches(entity Entity) bool

type IEntityFilter

type IEntityFilter interface {
	Matches(entity Entity) bool
}

func BuildEntityFilter

func BuildEntityFilter(filterStrings []string) ([]IEntityFilter, error)

type ILogger

type ILogger interface {
	Info(template string, args ...interface{})
	Debug(template string, args ...interface{})
	Error(template string, args ...interface{})

	SetLogLevelInfo()
	SetLogLevelDebug()
}

ILogger is the package logging interface

var Logger ILogger

func NewLogger

func NewLogger() ILogger

NewLogger creates a logger at log level Error

type LdifParser

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

LdifParser implements EntityBuilder and constructs LDAP Entities from an ldif file.

func NewLdifParser

func NewLdifParser(filename string) LdifParser

NewLdifParser returns a constructed LdifEntityBuilder with null filters.

func (LdifParser) BuildEntities

func (parser LdifParser) BuildEntities(entities chan Entity, done chan bool) error

BuildEntities constructs an ldap entity per entry in the input ldif file.

func (LdifParser) BuildEntity

func (parser LdifParser) BuildEntity(keyAttrName string, keyAttrVal string) (Entity, error)

BuildEntity returns an empty Entity object if the object is not found, other wise it returns the entity object or an error if one is encountered.

func (LdifParser) CountEntities added in v0.3.0

func (parser LdifParser) CountEntities() (count int, err error)

CountEntities returns the number of entities in the input file

func (*LdifParser) SetAttributeFilter

func (parser *LdifParser) SetAttributeFilter(filter internal.HashSetStr)

SetAttributeFilter modifies the parser to return only the ldap attributes present in the filter on entites that are parsed.

func (*LdifParser) SetEntityFilter

func (parser *LdifParser) SetEntityFilter(filter []IEntityFilter)

SetEntityFilter modifies the parser to return only entities matching the attribute / value pairs in the filter.

type PkgLogger

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

PkgLogger is the package logging implementation

func (PkgLogger) Debug

func (l PkgLogger) Debug(template string, args ...interface{})

func (PkgLogger) Error

func (l PkgLogger) Error(template string, args ...interface{})

func (PkgLogger) Info

func (l PkgLogger) Info(template string, args ...interface{})

func (PkgLogger) SetLogLevelDebug

func (l PkgLogger) SetLogLevelDebug()

SetLogLevelDebug sets the current log level to debug

func (PkgLogger) SetLogLevelInfo

func (l PkgLogger) SetLogLevelInfo()

SetLogLevelInfo sets the current log level to info

type PositionedScanner

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

func NewPositionedScanner

func NewPositionedScanner(inputStream io.Reader) *PositionedScanner

func (PositionedScanner) Buffer

func (ps PositionedScanner) Buffer(buffer []byte, max int)

func (PositionedScanner) Fork

func (PositionedScanner) Position

func (ps PositionedScanner) Position() int64

func (*PositionedScanner) Scan

func (ps *PositionedScanner) Scan() bool

func (PositionedScanner) Text

func (ps PositionedScanner) Text() string

type UACFilter

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

func NewUACFilter

func NewUACFilter(searchTerm int) UACFilter

func (UACFilter) Matches

func (filter UACFilter) Matches(entity Entity) (isMatch bool)

Jump to

Keyboard shortcuts

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