ldap

package module
v0.0.0-...-3e61dbb Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: BSD-2-Clause, BSD-3-Clause Imports: 14 Imported by: 2

README

LDAPv3 client package in pure Go

Implemented functionality

  • Connecting and binding to a LDAP server
  • Search / Modify / Add / Delete requests
  • Password modify request (RFC3062)
  • Compare request
  • Search filter compiling
  • Request Controls (MatchedValuesRequest, PermissiveModifyRequest, ManageDsaITRequest, SubtreeDeleteRequest, Paging, ServerSideSort)

Plans

  • Real tests against a LDAP server
  • I still have to decide what to do with things I will supposedly never touch or use, like the ldif writing/reading functionality
  • More cleaning
  • Modify DN request
  • Own type for DNs with methods for modification and escaping (like the escape_dn_chars function of the python ldap module)
  • Binary Attributes (there is another fork which implemented this, I think)

Licence

The licence used before this fork was copied from the Go sources. As I am not with Google, I added a 2-clause BSD license for this fork.

Documentation

Overview

This package provides LDAP client functions.

Index

Constants

View Source
const (
	MessageQuit     = 0
	MessageRequest  = 1
	MessageResponse = 2
	MessageFinish   = 3
)
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 (
	TagMatchingRule      = 1
	TagMatchingType      = 2
	TagMatchValue        = 3
	TagMatchDnAttributes = 4
)
View Source
const (
	DefaultTimeout       = 60 * time.Minute
	ResultChanBufferSize = 5 // buffer items in each chanResults default: 5
)
View Source
const (
	MatchingRule_numericStringOrderingMatch          = "2.5.13.9"                   // 1.3.6.1.4.1.1466.115.121.1.36
	MatchingRule_numericStringMatch                  = "2.5.13.8"                   // 1.3.6.1.4.1.1466.115.121.1.36
	MatchingRule_caseExactSubstringsMatch            = "2.5.13.7"                   // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_caseExactOrderingMatch              = "2.5.13.6"                   // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_caseExactMatch                      = "2.5.13.5"                   // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_caseIgnoreSubstringsMatch           = "2.5.13.4"                   // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_keywordMatch                        = "2.5.13.33"                  // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_wordMatch                           = "2.5.13.32"                  // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_directoryStringFirstComponentMatch  = "2.5.13.31"                  // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_objectIdentifierFirstComponentMatch = "2.5.13.30"                  // 1.3.6.1.4.1.1466.115.121.1.38
	MatchingRule_caseIgnoreOrderingMatch             = "2.5.13.3"                   // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_integerFirstComponentMatch          = "2.5.13.29"                  // 1.3.6.1.4.1.1466.115.121.1.27
	MatchingRule_generalizedTimeOrderingMatch        = "2.5.13.28"                  // 1.3.6.1.4.1.1466.115.121.1.24
	MatchingRule_generalizedTimeMatch                = "2.5.13.27"                  // 1.3.6.1.4.1.1466.115.121.1.24
	MatchingRule_protocolInformationMatch            = "2.5.13.24"                  // 1.3.6.1.4.1.1466.115.121.1.42
	MatchingRule_uniqueMemberMatch                   = "2.5.13.23"                  // 1.3.6.1.4.1.1466.115.121.1.34
	MatchingRule_presentationAddressMatch            = "2.5.13.22"                  // 1.3.6.1.4.1.1466.115.121.1.43
	MatchingRule_telephoneNumberSubstringsMatch      = "2.5.13.21"                  // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_telephoneNumberMatch                = "2.5.13.20"                  // 1.3.6.1.4.1.1466.115.121.1.50
	MatchingRule_caseIgnoreMatch                     = "2.5.13.2"                   // 1.3.6.1.4.1.1466.115.121.1.15
	MatchingRule_octetStringSubstringsMatch          = "2.5.13.19"                  // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_octetStringOrderingMatch            = "2.5.13.18"                  // 1.3.6.1.4.1.1466.115.121.1.40
	MatchingRule_octetStringMatch                    = "2.5.13.17"                  // 1.3.6.1.4.1.1466.115.121.1.40
	MatchingRule_bitStringMatch                      = "2.5.13.16"                  // 1.3.6.1.4.1.1466.115.121.1.6
	MatchingRule_integerOrderingMatch                = "2.5.13.15"                  // 1.3.6.1.4.1.1466.115.121.1.27
	MatchingRule_integerMatch                        = "2.5.13.14"                  // 1.3.6.1.4.1.1466.115.121.1.27
	MatchingRule_booleanMatch                        = "2.5.13.13"                  // 1.3.6.1.4.1.1466.115.121.1.7
	MatchingRule_caseIgnoreListSubstringsMatch       = "2.5.13.12"                  // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_caseIgnoreListMatch                 = "2.5.13.11"                  // 1.3.6.1.4.1.1466.115.121.1.41
	MatchingRule_numericStringSubstringsMatch        = "2.5.13.10"                  // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_distinguishedNameMatch              = "2.5.13.1"                   // 1.3.6.1.4.1.1466.115.121.1.12
	MatchingRule_objectIdentifierMatch               = "2.5.13.0"                   // 1.3.6.1.4.1.1466.115.121.1.38
	MatchingRule_authPasswordMatch                   = "1.3.6.1.4.1.4203.1.2.3"     // 1.3.6.1.4.1.4203.1.1.2 DESC 'authentication password matching rule'
	MatchingRule_authPasswordExactMatch              = "1.3.6.1.4.1.4203.1.2.2"     // 1.3.6.1.4.1.4203.1.1.2 DESC 'authentication password exact matching rule'
	MatchingRule_caseExactIA5SubstringsMatch         = "1.3.6.1.4.1.26027.1.4.902"  // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_partialDateAndTimeMatchingRule      = "1.3.6.1.4.1.26027.1.4.7"    // 1.3.6.1.4.1.1466.115.121.1.24
	MatchingRule_relativeTimeLTOrderingMatch         = "1.3.6.1.4.1.26027.1.4.6"    // 1.3.6.1.4.1.1466.115.121.1.24
	MatchingRule_relativeTimeGTOrderingMatch         = "1.3.6.1.4.1.26027.1.4.5"    // 1.3.6.1.4.1.1466.115.121.1.24
	MatchingRule_historicalCsnOrderingMatch          = "1.3.6.1.4.1.26027.1.4.4"    // 1.3.6.1.4.1.1466.115.121.1.40
	MatchingRule_ds_mr_user_password_equality        = "1.3.6.1.4.1.26027.1.4.3"    // 1.3.6.1.4.1.26027.1.3.1 DESC 'user password matching rule'
	MatchingRule_ds_mr_user_password_exact           = "1.3.6.1.4.1.26027.1.4.2"    // 1.3.6.1.4.1.26027.1.3.1 DESC 'user password exact matching rule'
	MatchingRule_ds_mr_double_metaphone_approx       = "1.3.6.1.4.1.26027.1.4.1"    // 1.3.6.1.4.1.26027.1.3.1 DESC 'Double Metaphone Approximate Match'
	MatchingRule_caseIgnoreIA5SubstringsMatch        = "1.3.6.1.4.1.1466.109.114.3" // 1.3.6.1.4.1.1466.115.121.1.58
	MatchingRule_caseIgnoreIA5Match                  = "1.3.6.1.4.1.1466.109.114.2" // 1.3.6.1.4.1.1466.115.121.1.26
	MatchingRule_caseExactIA5Match                   = "1.3.6.1.4.1.1466.109.114.1" // 1.3.6.1.4.1.1466.115.121.1.26
	MatchingRule_uuidOrderingMatch                   = "1.3.6.1.1.16.3"             // 1.3.6.1.1.16.1
	MatchingRule_uuidMatch                           = "1.3.6.1.1.16.2"             // 1.3.6.1.1.16.1
)

At the moment just helper values for ServerSideSorting.

View Source
const (
	FilterItem = 256
)

Variables

View Source
var FilterComponent = map[string]uint64{
	"&":  FilterAnd,
	"|":  FilterOr,
	"!":  FilterNot,
	"=":  FilterEqualityMatch,
	">=": FilterGreaterOrEqual,
	"<=": FilterLessOrEqual,
	"~=": FilterApproxMatch,
}
View Source
var FilterDebug bool = false
View Source
var FilterMap = map[uint64]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",
}
View Source
var FilterSubstringsMap = map[uint64]string{
	FilterSubstringsInitial: "Substrings Initial",
	FilterSubstringsAny:     "Substrings Any",
	FilterSubstringsFinal:   "Substrings Final",
}
View Source
var VlvDebug bool

Functions

func AttributeValueAssertion

func AttributeValueAssertion(attr, op, value string) (*ber.Packet, error)

func CompileFilter

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

func DebugBinaryFile

func DebugBinaryFile(FileName string) error

func DecompileFilter

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

func DnReplace

func DnReplace(value string) string

DnReplace replaces runes in AssertionValues as defined in RFC 4514 [https://www.ietf.org/rfc/rfc4514.txt]

func EscapeFilterValue

func EscapeFilterValue(filter string) string

func FilterReplace

func FilterReplace(value string) string

FilterReplace replaces runes in AssertionValues as defined in RFC 4515 [https://www.ietf.org/rfc/rfc4515.txt]

func UnescapeFilterValue

func UnescapeFilterValue(filter string) string

Types

type AddRequest

type AddRequest struct {
	Entry    *Entry
	Controls []Control
}

func NewAddRequest

func NewAddRequest(dn string) (req *AddRequest)

func (*AddRequest) AddAttribute

func (req *AddRequest) AddAttribute(attr *EntryAttribute)

func (*AddRequest) AddAttributes

func (req *AddRequest) AddAttributes(attrs []*EntryAttribute)

func (*AddRequest) AddControl

func (req *AddRequest) AddControl(control Control)

func (*AddRequest) Bytes

func (req *AddRequest) Bytes() []byte

func (*AddRequest) String

func (addReq *AddRequest) String() (dump string)

DumpAddRequest - Basic LDIF "like" dump for testing, no formating, etc

type ApplicationCode

type ApplicationCode ber.Tag

LDAP Application Codes

const (
	ApplicationBindRequest           ApplicationCode = 0
	ApplicationBindResponse          ApplicationCode = 1
	ApplicationUnbindRequest         ApplicationCode = 2
	ApplicationSearchRequest         ApplicationCode = 3
	ApplicationSearchResultEntry     ApplicationCode = 4
	ApplicationSearchResultDone      ApplicationCode = 5
	ApplicationModifyRequest         ApplicationCode = 6
	ApplicationModifyResponse        ApplicationCode = 7
	ApplicationAddRequest            ApplicationCode = 8
	ApplicationAddResponse           ApplicationCode = 9
	ApplicationDelRequest            ApplicationCode = 10
	ApplicationDelResponse           ApplicationCode = 11
	ApplicationModifyDNRequest       ApplicationCode = 12
	ApplicationModifyDNResponse      ApplicationCode = 13
	ApplicationCompareRequest        ApplicationCode = 14
	ApplicationCompareResponse       ApplicationCode = 15
	ApplicationAbandonRequest        ApplicationCode = 16
	ApplicationSearchResultReference ApplicationCode = 19
	ApplicationExtendedRequest       ApplicationCode = 23
	ApplicationExtendedResponse      ApplicationCode = 24
)

func (ApplicationCode) String

func (i ApplicationCode) String() string

type CompareRequest

type CompareRequest struct {
	DN       string
	Name     string
	Value    string
	Controls []Control
}

func NewCompareRequest

func NewCompareRequest(dn, name, value string) (req *CompareRequest)

type Connection

type Connection struct {
	IsTLS bool
	IsSSL bool
	Debug bool

	Addr                        string
	NetworkConnectTimeout       time.Duration
	ReadTimeout                 time.Duration
	AbandonMessageOnReadTimeout bool

	TlsConfig *tls.Config
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(address string) *Connection

NewConnection creates a new Connection object. The address is in the same format as used in the net package.

func NewSSLConnection

func NewSSLConnection(address string, tlsConfig *tls.Config) *Connection

Behaves like NewConnection, except that an additional parameter tlsConfig is expected. The resulting connection uses SSL.

func NewTLSConnection

func NewTLSConnection(address string, tlsConfig *tls.Config) *Connection

Behaves like NewConnection, except that an additional parameter tlsConfig is expected. The resulting connection uses TLS.

func (*Connection) Abandon

func (l *Connection) Abandon(abandonMessageID int64) error

Will return an error. Normally due to closed connection.

func (*Connection) Add

func (l *Connection) Add(req *AddRequest) error

func (*Connection) Bind

func (l *Connection) Bind(username, password string) error

Simple bind to the server. If using a timeout you should close the connection on a bind failure.

func (*Connection) Close

func (l *Connection) Close() error

Close closes the connection.

func (*Connection) Compare

func (l *Connection) Compare(req *CompareRequest) (bool, error)

func (*Connection) Connect

func (l *Connection) Connect() error

Connect connects using information in Connection. Connection should be populated with connection information.

func (*Connection) Delete

func (l *Connection) Delete(delReq *DeleteRequest) (error error)

func (*Connection) ModDn

func (l *Connection) ModDn(req *ModDnRequest) error

Untested.

func (*Connection) Modify

func (l *Connection) Modify(modReq *ModifyRequest) error

func (*Connection) Passwd

func (l *Connection) Passwd(req *PasswordModifyRequest) error

func (*Connection) Search

func (l *Connection) Search(searchRequest *SearchRequest) (*SearchResult, error)

Search is a blocking search. nil error on success.

func (*Connection) SearchWithHandler

func (l *Connection) SearchWithHandler(
	searchRequest *SearchRequest, resultHandler SearchResultHandler, errorChan chan<- error,
) error

SearchWithHandler is the workhorse. Sends requests, decodes results and passes on to SearchResultHandlers to process.

SearchResultHandler, an interface, implemeneted by SearchResult.
Handles the discreteSearchResults. Can provide own implemented to work on
a result by result basis.
errorChan - if nil then blocking, else error returned via channel upon completion.
returns error if blocking.

func (*Connection) SearchWithPaging

func (l *Connection) SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error)

SearchWithPaging adds a paging control to the the searchRequest, with a size of pagingSize. It combines all the paged results into the returned SearchResult. It is a helper function for use with servers that require paging for certain result sizes (AD?).

It is NOT an efficent way to process huge result sets i.e. it doesn't process on a pageSize number of entries, it returns the combined result.

type ConnectionInfo

type ConnectionInfo struct {
	Conn      *Connection
	MessageID int64
}

type Control

type Control interface {
	Encode() (*ber.Packet, error)
	GetControlType() ControlType
	String() string
}

Control Interface

func FindControl

func FindControl(controls []Control, controlType ControlType) (position int, control Control)

func NewControlPagingFromPacket

func NewControlPagingFromPacket(p *ber.Packet) (Control, error)

func NewControlServerSideSortResponse

func NewControlServerSideSortResponse(p *ber.Packet) (Control, error)
SortResult ::= SEQUENCE {
  sortResult  ENUMERATED {
      success                   (0), -- results are sorted
      operationsError           (1), -- server internal failure
      timeLimitExceeded         (3), -- timelimit reached before
                                     -- sorting was completed
      strongAuthRequired        (8), -- refused to return sorted
                                     -- results via insecure
                                     -- protocol
      adminLimitExceeded       (11), -- too many matching entries
                                     -- for the server to sort
      noSuchAttribute          (16), -- unrecognized attribute
                                     -- type in sort key
      inappropriateMatching    (18), -- unrecognized or
                                     -- inappropriate matching
                                     -- rule in sort key
      insufficientAccessRights (50), -- refused to return sorted
                                     -- results to this client
      busy                     (51), -- too busy to process
      unwillingToPerform       (53), -- unable to sort
      other                    (80)
      },
  attributeType [0] AttributeDescription OPTIONAL }

func NewControlStringFromPacket

func NewControlStringFromPacket(p *ber.Packet) (Control, error)

func NewControlVlvResponse

func NewControlVlvResponse(p *ber.Packet) (Control, error)
VirtualListViewResponse ::= SEQUENCE {
      targetPosition    INTEGER (0 .. maxInt),
      contentCount     INTEGER (0 .. maxInt),
      virtualListViewResult ENUMERATED {
           success (0),
           operationsError (1),
           protocolError (3),
           unwillingToPerform (53),
           insufficientAccessRights (50),
           timeLimitExceeded (3),
           adminLimitExceeded (11),
           innapropriateMatching (18),
           sortControlMissing (60),
           offsetRangeError (61),
           other(80),
           ... },
      contextID     OCTET STRING OPTIONAL }

func ReplaceControl

func ReplaceControl(controls []Control, control Control) (oldControl Control)

type ControlMatchedValuesRequest

type ControlMatchedValuesRequest struct {
	Criticality bool
	Filter      string
}

func NewControlMatchedValuesRequest

func NewControlMatchedValuesRequest(criticality bool, filter string) *ControlMatchedValuesRequest

func (*ControlMatchedValuesRequest) Decode

func (c *ControlMatchedValuesRequest) Decode(p *ber.Packet) (*Control, error)

func (*ControlMatchedValuesRequest) Encode

func (c *ControlMatchedValuesRequest) Encode() (p *ber.Packet, err error)

func (*ControlMatchedValuesRequest) GetControlType

func (c *ControlMatchedValuesRequest) GetControlType() ControlType

func (*ControlMatchedValuesRequest) String

func (c *ControlMatchedValuesRequest) String() string

type ControlPaging

type ControlPaging struct {
	PagingSize uint32
	Cookie     []byte
}

func NewControlPaging

func NewControlPaging(PagingSize uint32) *ControlPaging

func (*ControlPaging) Encode

func (c *ControlPaging) Encode() (p *ber.Packet, err error)

func (*ControlPaging) GetControlType

func (c *ControlPaging) GetControlType() ControlType

func (*ControlPaging) SetCookie

func (c *ControlPaging) SetCookie(Cookie []byte)

func (*ControlPaging) String

func (c *ControlPaging) String() string

type ControlServerSideSortRequest

type ControlServerSideSortRequest struct {
	SortKeyList []ServerSideSortAttrRuleOrder
	Criticality bool
}

func NewControlServerSideSortRequest

func NewControlServerSideSortRequest(sortKeyList []ServerSideSortAttrRuleOrder, criticality bool) *ControlServerSideSortRequest

func (*ControlServerSideSortRequest) Decode

func (c *ControlServerSideSortRequest) Decode(p *ber.Packet) (*Control, error)

func (*ControlServerSideSortRequest) Encode

func (c *ControlServerSideSortRequest) Encode() (p *ber.Packet, err error)

func (*ControlServerSideSortRequest) GetControlType

func (c *ControlServerSideSortRequest) GetControlType() ControlType

func (*ControlServerSideSortRequest) String

type ControlServerSideSortResponse

type ControlServerSideSortResponse struct {
	AttributeName string // Optional
	Criticality   bool
	Err           error
}

func (*ControlServerSideSortResponse) Encode

func (c *ControlServerSideSortResponse) Encode() (p *ber.Packet, err error)

func (*ControlServerSideSortResponse) GetControlType

func (c *ControlServerSideSortResponse) GetControlType() ControlType

func (*ControlServerSideSortResponse) String

type ControlString

type ControlString struct {
	ControlType  ControlType
	Criticality  bool
	ControlValue string
}

func NewControlManageDsaITRequest

func NewControlManageDsaITRequest(criticality bool) *ControlString

func NewControlNoOpRequest

func NewControlNoOpRequest() *ControlString

func NewControlPermissiveModifyRequest

func NewControlPermissiveModifyRequest(criticality bool) *ControlString

func NewControlString

func NewControlString(ControlType ControlType, Criticality bool, ControlValue string) *ControlString

func NewControlSubtreeDeleteRequest

func NewControlSubtreeDeleteRequest(criticality bool) *ControlString

func (*ControlString) Encode

func (c *ControlString) Encode() (p *ber.Packet, err error)

func (*ControlString) GetControlType

func (c *ControlString) GetControlType() ControlType

func (*ControlString) String

func (c *ControlString) String() string

type ControlType

type ControlType string
const (
	ControlTypeMatchedValuesRequest    ControlType = "1.2.826.0.1.3344810.2.3"
	ControlTypePermissiveModifyRequest ControlType = "1.2.840.113556.1.4.1413"
	ControlTypePaging                  ControlType = "1.2.840.113556.1.4.319"
	ControlTypeManageDsaITRequest      ControlType = "2.16.840.1.113730.3.4.2"
	ControlTypeSubtreeDeleteRequest    ControlType = "1.2.840.113556.1.4.805"
	ControlTypeNoOpRequest             ControlType = "1.3.6.1.4.1.4203.1.10.2"
	ControlTypeServerSideSortRequest   ControlType = "1.2.840.113556.1.4.473"
	ControlTypeServerSideSortResponse  ControlType = "1.2.840.113556.1.4.474"
	ControlTypeVlvRequest              ControlType = "2.16.840.1.113730.3.4.9"
	ControlTypeVlvResponse             ControlType = "2.16.840.1.113730.3.4.10"
)

func (ControlType) String

func (c ControlType) String() string

type ControlVlvRequest

type ControlVlvRequest struct {
	Criticality        bool
	BeforeCount        int32
	AfterCount         int32
	ByOffset           *VlvOffSet
	GreaterThanOrEqual string
	ContextID          []byte
}
VirtualListViewRequest ::= SEQUENCE {
     beforeCount    INTEGER (0..maxInt),
     afterCount     INTEGER (0..maxInt),
     target       CHOICE {
                    byOffset        [0] SEQUENCE {
                         offset          INTEGER (1 .. maxInt),
                         contentCount    INTEGER (0 .. maxInt) },
                    greaterThanOrEqual [1] AssertionValue },
     contextID     OCTET STRING OPTIONAL }

func (*ControlVlvRequest) Encode

func (c *ControlVlvRequest) Encode() (*ber.Packet, error)

func (*ControlVlvRequest) GetControlType

func (c *ControlVlvRequest) GetControlType() string

func (*ControlVlvRequest) String

func (c *ControlVlvRequest) String() string

type ControlVlvResponse

type ControlVlvResponse struct {
	Criticality    bool
	TargetPosition uint64
	ContentCount   uint64
	Err            error // VirtualListViewResult
	ContextID      string
}

func (*ControlVlvResponse) Encode

func (c *ControlVlvResponse) Encode() (p *ber.Packet, err error)

func (*ControlVlvResponse) GetControlType

func (c *ControlVlvResponse) GetControlType() ControlType

func (*ControlVlvResponse) String

func (c *ControlVlvResponse) String() string

type DeleteRequest

type DeleteRequest struct {
	DN       string
	Controls []Control
}

func NewDeleteRequest

func NewDeleteRequest(dn string) (delReq *DeleteRequest)

func (*DeleteRequest) AddControl

func (delReq *DeleteRequest) AddControl(control Control)

TDDO make generic for mod/del/search via interface.

type Deref

type Deref uint8
const (
	NeverDerefAliases   Deref = 0
	DerefInSearching    Deref = 1
	DerefFindingBaseObj Deref = 2
	DerefAlways         Deref = 3
)

func (Deref) String

func (i Deref) String() string

type DiscreteSearchResult

type DiscreteSearchResult struct {
	SearchResultType SearchResultType
	Entry            *Entry
	Referrals        []string
	Controls         []Control
}

type Entry

type Entry struct {
	DN         string
	Attributes []*EntryAttribute
}

func NewEntry

func NewEntry(dn string) *Entry

func (*Entry) AddAttributeValue

func (e *Entry) AddAttributeValue(attributeName, value string)

AddAttributeValue - Add a single Attr value no check is done for duplicate values.

func (*Entry) AddAttributeValues

func (e *Entry) AddAttributeValues(attributeName string, values []string)

AddAttributeValues - Add via a name and slice of values no check is done for duplicate values.

func (*Entry) GetAttributeIndex

func (e *Entry) GetAttributeIndex(attributeName string) int

func (*Entry) GetAttributeValue

func (e *Entry) GetAttributeValue(attributeName string) string

GetAttributeValue - returning an empty string is a bad idea some directory servers will return empty attr values (Sunone). Just asking for trouble.

func (*Entry) GetAttributeValues

func (e *Entry) GetAttributeValues(attributeName string) []string

func (*Entry) String

func (e *Entry) String() string

TODO: Proper LDIF writer, currently just for testing...

type EntryAttribute

type EntryAttribute struct {
	Name   string
	Values []string
}

type Error

type Error struct {
	ResultCode ResultCode
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

type Mod

type Mod struct {
	ModOperation ModificationCode
	Modification EntryAttribute
}

func NewMod

func NewMod(modType ModificationCode, attr string, values []string) (mod *Mod)

func (*Mod) DumpMod

func (mod *Mod) DumpMod() (dump string)

Basic LDIF dump, no formating, etc

type ModDnRequest

type ModDnRequest struct {
	DN            string
	NewRDN        string
	DeleteOldDn   bool
	NewSuperiorDN string
	Controls      []Control
}

type ModificationCode

type ModificationCode uint8

LDAP Modification operation codes

const (
	ModAdd     ModificationCode = 0
	ModDelete  ModificationCode = 1
	ModReplace ModificationCode = 2
	// Modify-Increment Extension [https://tools.ietf.org/html/rfc4525]
	ModIncrement ModificationCode = 3
)

func (ModificationCode) String

func (i ModificationCode) String() string

type ModifyRequest

type ModifyRequest struct {
	// DN of entry that is modified
	DN string

	// Changes
	Mods []Mod

	// Server controls
	Controls []Control
}

LDAP modify request [https://tools.ietf.org/html/rfc4511#section-4.6]

func NewModifyRequest

func NewModifyRequest(dn string) (req *ModifyRequest)

func (*ModifyRequest) AddControl

func (req *ModifyRequest) AddControl(control Control)

func (*ModifyRequest) AddMod

func (req *ModifyRequest) AddMod(mod *Mod)

func (*ModifyRequest) AddMods

func (req *ModifyRequest) AddMods(mods []Mod)

func (*ModifyRequest) Bytes

func (req *ModifyRequest) Bytes() []byte

func (*ModifyRequest) String

func (req *ModifyRequest) String() (dump string)

Basic LDIF dump, no formating, etc

type PasswordModifyRequest

type PasswordModifyRequest struct {
	UserIdentity string
	OldPasswd    string
	NewPasswd    string
}

PasswordModifyRequest implements the payload and encoding specified in https://tools.ietf.org/html/rfc3062

func (*PasswordModifyRequest) Encode

func (r *PasswordModifyRequest) Encode() (*ber.Packet, error)

Encode the PasswordModifyRequest into a ber.Packet

type ResultCode

type ResultCode uint8

LDAP Result Codes

const (
	ResultSuccess                      ResultCode = 0
	ResultOperationsError              ResultCode = 1
	ResultProtocolError                ResultCode = 2
	ResultTimeLimitExceeded            ResultCode = 3
	ResultSizeLimitExceeded            ResultCode = 4
	ResultCompareFalse                 ResultCode = 5
	ResultCompareTrue                  ResultCode = 6
	ResultAuthMethodNotSupported       ResultCode = 7
	ResultStrongAuthRequired           ResultCode = 8
	ResultReferral                     ResultCode = 10
	ResultAdminLimitExceeded           ResultCode = 11
	ResultUnavailableCriticalExtension ResultCode = 12
	ResultConfidentialityRequired      ResultCode = 13
	ResultSaslBindInProgress           ResultCode = 14
	ResultNoSuchAttribute              ResultCode = 16
	ResultUndefinedAttributeType       ResultCode = 17
	ResultInappropriateMatching        ResultCode = 18
	ResultConstraintViolation          ResultCode = 19
	ResultAttributeOrValueExists       ResultCode = 20
	ResultInvalidAttributeSyntax       ResultCode = 21
	ResultNoSuchObject                 ResultCode = 32
	ResultAliasProblem                 ResultCode = 33
	ResultInvalidDNSyntax              ResultCode = 34
	ResultAliasDereferencingProblem    ResultCode = 36
	ResultInappropriateAuthentication  ResultCode = 48
	ResultInvalidCredentials           ResultCode = 49
	ResultInsufficientAccessRights     ResultCode = 50
	ResultBusy                         ResultCode = 51
	ResultUnavailable                  ResultCode = 52
	ResultUnwillingToPerform           ResultCode = 53
	ResultLoopDetect                   ResultCode = 54
	ResultNamingViolation              ResultCode = 64
	ResultObjectClassViolation         ResultCode = 65
	ResultNotAllowedOnNonLeaf          ResultCode = 66
	ResultNotAllowedOnRDN              ResultCode = 67
	ResultEntryAlreadyExists           ResultCode = 68
	ResultObjectClassModsProhibited    ResultCode = 69
	ResultAffectsMultipleDSAs          ResultCode = 71
	ResultOther                        ResultCode = 80

	ErrorNetwork         = 201
	ErrorFilterCompile   = 202
	ErrorFilterDecompile = 203
	ErrorDebugging       = 204
	ErrorEncoding        = 205
	ErrorDecoding        = 206
	ErrorMissingControl  = 207
	ErrorInvalidArgument = 208
	ErrorLDIFRead        = 209
	ErrorLDIFWrite       = 210
	ErrorClosing         = 211
	ErrorUnknown         = 212
)

go:generate stringer -type=ResultCode

func (ResultCode) String

func (i ResultCode) String() string

type Scope

type Scope uint8
const (
	ScopeBaseObject   Scope = 0
	ScopeSingleLevel  Scope = 1
	ScopeWholeSubtree Scope = 2
)

func (Scope) String

func (i Scope) String() string

type SearchRequest

type SearchRequest struct {
	BaseDN       string
	Scope        Scope
	DerefAliases Deref
	SizeLimit    int
	TimeLimit    int
	TypesOnly    bool
	Filter       string
	Attributes   []string
	Controls     []Control
}

SearchRequest passed to Search functions.

func NewSearchRequest

func NewSearchRequest(BaseDN string, Scope Scope, DerefAliases Deref, SizeLimit, TimeLimit int, TypesOnly bool, Filter string, Attributes []string, Controls []Control) *SearchRequest

func NewSimpleSearchRequest

func NewSimpleSearchRequest(BaseDN string, Scope Scope, Filter string, Attributes []string) *SearchRequest

NewSimpleSearchRequest only requires four parameters and defaults the other returned SearchRequest values to typical values...

DerefAliases: NeverDerefAliases
SizeLimit:    0
TimeLimit:    0
TypesOnly:    false
Controls:     nil

func (*SearchRequest) AddControl

func (req *SearchRequest) AddControl(control Control)

AddControl adds the provided control to a SearchRequest

type SearchResult

type SearchResult struct {
	Entries   []*Entry
	Referrals []string
	Controls  []Control
}

func (*SearchResult) ProcessDiscreteResult

func (sr *SearchResult) ProcessDiscreteResult(dsr *DiscreteSearchResult, connInfo *ConnectionInfo) (stopProcessing bool, err error)

ProcessDiscreteResult handles an individual result from a server. Member of the SearchResultHandler interface. Results are placed into a SearchResult.

func (*SearchResult) String

func (sr *SearchResult) String() (dump string)

type SearchResultHandler

type SearchResultHandler interface {
	ProcessDiscreteResult(*DiscreteSearchResult, *ConnectionInfo) (bool, error)
}

type SearchResultType

type SearchResultType uint8

func (SearchResultType) String

func (i SearchResultType) String() string

type ServerSideSortAttrRuleOrder

type ServerSideSortAttrRuleOrder struct {
	AttributeName string
	OrderingRule  string
	ReverseOrder  bool
}

type ValueMismatchError

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

func NewValueMismatchError

func NewValueMismatchError(got interface{}) *ValueMismatchError

func (*ValueMismatchError) Error

func (v *ValueMismatchError) Error() string

type VlvOffSet

type VlvOffSet struct {
	Offset       int32
	ContentCount int32
}

Jump to

Keyboard shortcuts

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