ldapquery

package
v0.0.0-...-307f9dc Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 71

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEntryNotFoundError

func IsEntryNotFoundError(err error) bool

func IsNoSuchObjectError

func IsNoSuchObjectError(err error) bool

IsNoSuchObjectError determines if the error is a NoSuchObjectError or if it is the upstream version of the error If this returns true, you are *not* safe to cast the error to a NoSuchObjectError

func IsQueryOutOfBoundsError

func IsQueryOutOfBoundsError(err error) bool

func NewEntryNotFoundError

func NewEntryNotFoundError(baseDN, filter string) error

func NewNoSuchObjectError

func NewNoSuchObjectError(baseDN string) error

func NewQueryOutOfBoundsError

func NewQueryOutOfBoundsError(queryDN, baseDN string) error

func QueryForEntries

func QueryForEntries(ldapClient ldap.Client, query *ldap.SearchRequest) ([]*ldap.Entry, error)

QueryForEntries queries for LDAP with the given searchRequest

func QueryForUniqueEntry

func QueryForUniqueEntry(ldapClient ldap.Client, query *ldap.SearchRequest) (*ldap.Entry, error)

QueryForUniqueEntry queries for an LDAP entry with the given searchRequest. The query is expected to return one unqiue result. If this is not the case, errors are raised

Types

type LDAPQuery

type LDAPQuery struct {
	// The DN of the branch of the directory where all searches should start from
	BaseDN string

	// The (optional) scope of the search. Defaults to the entire subtree if not set
	Scope ldaputil.Scope

	// The (optional) behavior of the search with regards to alisases. Defaults to always
	// dereferencing if not set
	DerefAliases ldaputil.DerefAliases

	// TimeLimit holds the limit of time in seconds that any request to the server can remain outstanding
	// before the wait for a response is given up. If this is 0, no client-side limit is imposed
	TimeLimit int

	// Filter is a valid LDAP search filter that retrieves all relevant entries from the LDAP server with the base DN
	Filter string

	// PageSize is the maximum preferred page size, measured in LDAP entries. A page size of 0 means no paging will be done.
	PageSize int
}

LDAPQuery encodes an LDAP query

func NewLDAPQuery

func NewLDAPQuery(config SerializeableLDAPQuery) (LDAPQuery, error)

NewLDAPQuery converts a user-provided LDAPQuery into a version we can use

func (*LDAPQuery) NewSearchRequest

func (q *LDAPQuery) NewSearchRequest(additionalAttributes []string) *ldap.SearchRequest

NewSearchRequest creates a new search request for the LDAP query and optionally includes more attributes

type LDAPQueryOnAttribute

type LDAPQueryOnAttribute struct {
	// Query retrieves entries from an LDAP server
	LDAPQuery

	// QueryAttribute is the attribute for a specific filter that, when conjoined with the common filter,
	// retrieves the specific LDAP entry from the LDAP server. (e.g. "cn", when formatted with "aGroupName"
	// and conjoined with "objectClass=groupOfNames", becomes (&(objectClass=groupOfNames)(cn=aGroupName))")
	QueryAttribute string
}

LDAPQueryOnAttribute encodes an LDAP query that conjoins two filters to extract a specific LDAP entry This query is not self-sufficient and needs the value of the QueryAttribute to construct the final filter

func NewLDAPQueryOnAttribute

func NewLDAPQueryOnAttribute(config SerializeableLDAPQuery, attribute string) (LDAPQueryOnAttribute, error)

NewLDAPQueryOnAttribute converts a user-provided LDAPQuery into a version we can use by parsing the input and combining it with a set of name attributes

func (*LDAPQueryOnAttribute) NewSearchRequest

func (o *LDAPQueryOnAttribute) NewSearchRequest(attributeValue string, attributes []string) (*ldap.SearchRequest, error)

NewSearchRequest creates a new search request from the identifying query by internalizing the value of the attribute to be filtered as well as any attributes that need to be recovered

type SerializeableLDAPQuery

type SerializeableLDAPQuery struct {
	// The DN of the branch of the directory where all searches should start from
	BaseDN string

	// The (optional) scope of the search. Can be:
	// base: only the base object,
	// one:  all object on the base level,
	// sub:  the entire subtree
	// Defaults to the entire subtree if not set
	Scope string

	// The (optional) behavior of the search with regards to alisases. Can be:
	// never:  never dereference aliases,
	// search: only dereference in searching,
	// base:   only dereference in finding the base object,
	// always: always dereference
	// Defaults to always dereferencing if not set
	DerefAliases string

	// TimeLimit holds the limit of time in seconds that any request to the server can remain outstanding
	// before the wait for a response is given up. If this is 0, no client-side limit is imposed
	TimeLimit int

	// Filter is a valid LDAP search filter that retrieves all relevant entries from the LDAP server with the base DN
	Filter string

	// PageSize is the maximum preferred page size, measured in LDAP entries. A page size of 0 means no paging will be done.
	PageSize int
}

Jump to

Keyboard shortcuts

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