Documentation ¶
Index ¶
- Constants
- Variables
- func IsPrintable(v []byte) bool
- type AND
- type AddRequest
- type AddResponse
- type ApproxMatch
- type AttributeValueAssertion
- type Backend
- type BaseResponse
- type BindRequest
- type BindResponse
- type Class
- type Client
- func (c *Client) Bind(dn string, pass []byte) error
- func (c *Client) Close() error
- func (c *Client) Delete(dn string) error
- func (c *Client) Modify(dn string, mods []*Mod) error
- func (c *Client) Search(req *SearchRequest) ([]*SearchResult, error)
- func (c *Client) StartTLS(config *tls.Config) error
- func (c *Client) WhoAmI() (string, error)
- type DeleteRequest
- type DeleteResponse
- type DerefAliases
- type EqualityMatch
- type ErrFilterSyntaxError
- type ExtendedRequest
- type ExtendedResponse
- type ExtensibleMatch
- type Filter
- type GreaterOrEqual
- type InvalidBEREncodingError
- type LessOrEqual
- type Mod
- type ModType
- type ModifyDNRequest
- type ModifyDNResponse
- type ModifyRequest
- type ModifyResponse
- type NOT
- type OR
- type Packet
- func (p *Packet) AddItem(it *Packet) *Packet
- func (p *Packet) Bool() (bool, bool)
- func (p *Packet) Bytes() ([]byte, bool)
- func (p *Packet) Encode() ([]byte, error)
- func (p *Packet) Format(w io.Writer) error
- func (p *Packet) Int() (int, bool)
- func (p *Packet) Size() (int, int, error)
- func (p *Packet) Str() (string, bool)
- func (p *Packet) Uint() (uint, bool)
- func (p *Packet) Write(w io.Writer) error
- type PasswordModifyRequest
- type PasswordModifyResponse
- type Present
- type ProtocolError
- type Request
- type Response
- type ResultCode
- type Scope
- type SearchRequest
- type SearchResponse
- type SearchResult
- type Server
- type State
- type Substrings
- type UnsupportedRequestTagError
Constants ¶
const ( TagEOC = 0x00 TagBoolean = 0x01 TagInteger = 0x02 TagBitString = 0x03 TagOctetString = 0x04 TagNULL = 0x05 TagObjectIdentifier = 0x06 TagObjectDescriptor = 0x07 TagExternal = 0x08 TagRealFloat = 0x09 TagEnumerated = 0x0a TagEmbeddedPDV = 0x0b TagUTF8String = 0x0c TagRelativeOID = 0x0d TagSequence = 0x10 TagSet = 0x11 TagNumericString = 0x12 TagPrintableString = 0x13 TagT61String = 0x14 TagVideotexString = 0x15 TagIA5String = 0x16 TagUTCTime = 0x17 TagGeneralizedTime = 0x18 TagGraphicString = 0x19 TagVisibleString = 0x1a TagGeneralString = 0x1b TagUniversalString = 0x1c TagCharacterString = 0x1d TagBMPString = 0x1e )
const ( OIDContentSynchControl = "1.3.6.1.4.1.4203.1.9.1.1" // https://tools.ietf.org/html/rfc4533 OIDProxiedAuthControl = "2.16.840.1.113730.3.4.18" // https://tools.ietf.org/html/rfc4370 OIDNamedSubordinateReferenceControl = "2.16.840.1.113730.3.4.2" // https://tools.ietf.org/html/rfc3296 )
Controls
const ( OIDCancel = "1.3.6.1.1.8" // https://tools.ietf.org/html/rfc3909 OIDStartTLS = "1.3.6.1.4.1.1466.20037" // http://www.iana.org/go/rfc4511 - http://www.iana.org/go/rfc4513 OIDPasswordModify = "1.3.6.1.4.1.4203.1.11.1" // http://www.iana.org/go/rfc3062 OIDWhoAmI = "1.3.6.1.4.1.4203.1.11.3" // http://www.iana.org/go/rfc4532 )
Extensions
const ( OIDModifyIncrement = "1.3.6.1.1.14" // http://www.iana.org/go/rfc4525 OIDAllOperationalAttributes = "1.3.6.1.4.1.4203.1.5.1" // https://www.rfc-editor.org/rfc/rfc3673.txt OIDAttributesByObjectClass = "1.3.6.1.4.1.4203.1.5.2" // https://tools.ietf.org/html/rfc4529 OIDTrueFalseFilters = "1.3.6.1.4.1.4203.1.5.3" // https://tools.ietf.org/html/rfc4526 OIDLanguageTagOptions = "1.3.6.1.4.1.4203.1.5.4" // https://tools.ietf.org/html/rfc3866 OIDLanguageRangeOptions = "1.3.6.1.4.1.4203.1.5.5" // http://tools.ietf.org/html/rfc3866 )
Features
const ( ApplicationBindRequest = 0 ApplicationBindResponse = 1 ApplicationUnbindRequest = 2 ApplicationSearchRequest = 3 ApplicationSearchResultEntry = 4 ApplicationSearchResultDone = 5 ApplicationModifyRequest = 6 ApplicationModifyResponse = 7 ApplicationAddRequest = 8 ApplicationAddResponse = 9 ApplicationDelRequest = 10 ApplicationDelResponse = 11 ApplicationModifyDNRequest = 12 ApplicationModifyDNResponse = 13 ApplicationCompareRequest = 14 ApplicationCompareResponse = 15 ApplicationAbandonRequest = 16 ApplicationSearchResultReference = 19 ApplicationExtendedRequest = 23 ApplicationExtendedResponse = 24 )
Variables ¶
var ApplicationMap = map[uint8]string{ ApplicationBindRequest: "Bind Request", ApplicationBindResponse: "Bind Response", ApplicationUnbindRequest: "Unbind Request", ApplicationSearchRequest: "Search Request", ApplicationSearchResultEntry: "Search Result Entry", ApplicationSearchResultDone: "Search Result Done", ApplicationModifyRequest: "Modify Request", ApplicationModifyResponse: "Modify Response", ApplicationAddRequest: "Add Request", ApplicationAddResponse: "Add Response", ApplicationDelRequest: "Del Request", ApplicationDelResponse: "Del Response", ApplicationModifyDNRequest: "Modify DN Request", ApplicationModifyDNResponse: "Modify DN Response", ApplicationCompareRequest: "Compare Request", ApplicationCompareResponse: "Compare Response", ApplicationAbandonRequest: "Abandon Request", ApplicationSearchResultReference: "Search Result Reference", ApplicationExtendedRequest: "Extended Request", ApplicationExtendedResponse: "Extended Response", }
var ClassNames = map[Class]string{ ClassUniversal: "Universal", ClassApplication: "Application", ClassContext: "Context", ClassPrivate: "Private", }
var DerefMap = map[DerefAliases]string{ NeverDerefAliases: "NeverDerefAliases", DerefInSearching: "DerefInSearching", DerefFindingBaseObj: "DerefFindingBaseObj", DerefAlways: "DerefAlways", }
var ErrAlreadyTLS = errors.New("ldap: connection already using TLS")
ErrAlreadyTLS is returned when trying to start a TLS connection when the connection is already using TLS
var ResultCodeMap = map[ResultCode]string{ ResultSuccess: "Success", ResultOperationsError: "Operations Error", ResultProtocolError: "Protocol Error", ResultTimeLimitExceeded: "Time Limit Exceeded", ResultSizeLimitExceeded: "Size Limit Exceeded", ResultCompareFalse: "Compare False", ResultCompareTrue: "Compare True", ResultAuthMethodNotSupported: "Auth Method Not Supported", ResultStrongAuthRequired: "Strong Auth Required", ResultReferral: "Referral", ResultAdminLimitExceeded: "Admin Limit Exceeded", ResultUnavailableCriticalExtension: "Unavailable Critical Extension", ResultConfidentialityRequired: "Confidentiality Required", ResultSaslBindInProgress: "Sasl Bind In Progress", ResultNoSuchAttribute: "No Such Attribute", ResultUndefinedAttributeType: "Undefined Attribute Type", ResultInappropriateMatching: "Inappropriate Matching", ResultConstraintViolation: "Constraint Violation", ResultAttributeOrValueExists: "Attribute Or Value Exists", ResultInvalidAttributeSyntax: "Invalid Attribute Syntax", ResultNoSuchObject: "No Such Object", ResultAliasProblem: "Alias Problem", ResultInvalidDNSyntax: "Invalid DN Syntax", ResultAliasDereferencingProblem: "Alias Dereferencing Problem", ResultInappropriateAuthentication: "Inappropriate Authentication", ResultInvalidCredentials: "Invalid Credentials", ResultInsufficientAccessRights: "Insufficient Access Rights", ResultBusy: "Busy", ResultUnavailable: "Unavailable", ResultUnwillingToPerform: "Unwilling To Perform", ResultLoopDetect: "Loop Detect", ResultNamingViolation: "Naming Violation", ResultObjectClassViolation: "Object Class Violation", ResultNotAllowedOnNonLeaf: "Not Allowed On Non Leaf", ResultNotAllowedOnRDN: "Not Allowed On RDN", ResultEntryAlreadyExists: "Entry Already Exists", ResultObjectClassModsProhibited: "Object Class Mods Prohibited", ResultAffectsMultipleDSAs: "Affects Multiple DSAs", ResultOther: "Other", }
var RootDSE = map[string][]string{ "supportedLDAPVersion": []string{ "3", }, "supportedFeatures": []string{ OIDModifyIncrement, OIDAllOperationalAttributes, }, "supportedExtension": []string{ OIDWhoAmI, OIDPasswordModify, }, "supportedSASLMechanisms": []string{}, }
var ScopeMap = map[Scope]string{ ScopeBaseObject: "Base Object", ScopeSingleLevel: "Single Level", ScopeWholeSubtree: "Whole Subtree", ScopeChildren: "Children", }
var TagNames = map[int]string{ TagEOC: "EOC (End-of-Content)", TagBoolean: "Boolean", TagInteger: "Integer", TagBitString: "Bit String", TagOctetString: "Octet String", TagNULL: "NULL", TagObjectIdentifier: "Object Identifier", TagObjectDescriptor: "Object Descriptor", TagExternal: "External", TagRealFloat: "Real (float)", TagEnumerated: "Enumerated", TagEmbeddedPDV: "Embedded PDV", TagUTF8String: "UTF8 String", TagRelativeOID: "Relative-OID", TagSequence: "Sequence and Sequence of", TagSet: "Set and Set OF", TagNumericString: "Numeric String", TagPrintableString: "Printable String", TagT61String: "T61 String", TagVideotexString: "Videotex String", TagIA5String: "IA5 String", TagUTCTime: "UTC Time", TagGeneralizedTime: "Generalized Time", TagGraphicString: "Graphic String", TagVisibleString: "Visible String", TagGeneralString: "General String", TagUniversalString: "Universal String", TagCharacterString: "Character String", TagBMPString: "BMP String", }
Functions ¶
func IsPrintable ¶
Types ¶
type AddRequest ¶
type AddResponse ¶
type AddResponse struct {
BaseResponse
}
func (*AddResponse) WritePackets ¶
func (r *AddResponse) WritePackets(w io.Writer, msgID int) error
type ApproxMatch ¶
type ApproxMatch AttributeValueAssertion
func (*ApproxMatch) Encode ¶
func (f *ApproxMatch) Encode() (*Packet, error)
func (*ApproxMatch) String ¶
func (f *ApproxMatch) String() string
type AttributeValueAssertion ¶
type Backend ¶
type Backend interface { Add(context.Context, State, *AddRequest) (*AddResponse, error) Bind(context.Context, State, *BindRequest) (*BindResponse, error) Connect(remoteAddr net.Addr) (State, error) Delete(context.Context, State, *DeleteRequest) (*DeleteResponse, error) Disconnect(State) ExtendedRequest(context.Context, State, *ExtendedRequest) (*ExtendedResponse, error) Modify(context.Context, State, *ModifyRequest) (*ModifyResponse, error) ModifyDN(context.Context, State, *ModifyDNRequest) (*ModifyDNResponse, error) PasswordModify(context.Context, State, *PasswordModifyRequest) ([]byte, error) Search(context.Context, State, *SearchRequest) (*SearchResponse, error) Whoami(context.Context, State) (string, error) }
Backend is implemented by an LDAP database to provide the backing store
var DebugBackend Backend = debugBackend{}
DebugBackend is an implementation of a server backend that prints out requests
type BaseResponse ¶
type BaseResponse struct { MessageType int Code ResultCode MatchedDN string Message string }
func (*BaseResponse) Err ¶
func (r *BaseResponse) Err() error
func (*BaseResponse) Error ¶
func (r *BaseResponse) Error() string
func (*BaseResponse) NewPacket ¶
func (r *BaseResponse) NewPacket() *Packet
func (*BaseResponse) WritePackets ¶
func (r *BaseResponse) WritePackets(w io.Writer, msgID int) error
type BindRequest ¶
func (*BindRequest) WritePackets ¶
func (r *BindRequest) WritePackets(w io.Writer, msgID int) error
type BindResponse ¶
type BindResponse struct {
BaseResponse
}
func (*BindResponse) WritePackets ¶
func (r *BindResponse) WritePackets(w io.Writer, msgID int) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient returns a new initialized client using the provided existing connection. The provided connection should be considered owned by the Client and not used after this call.
func (*Client) Modify ¶
Modify operation allows a client to request that a modification of an entry be performed on its behalf by a server.
func (*Client) Search ¶
func (c *Client) Search(req *SearchRequest) ([]*SearchResult, error)
Search performs a search query against the LDAP database.
type DeleteRequest ¶
type DeleteRequest struct {
DN string
}
func (*DeleteRequest) WritePackets ¶
func (r *DeleteRequest) WritePackets(w io.Writer, msgID int) error
type DeleteResponse ¶
type DeleteResponse struct {
BaseResponse
}
func (*DeleteResponse) WritePackets ¶
func (r *DeleteResponse) WritePackets(w io.Writer, msgID int) error
type DerefAliases ¶
type DerefAliases int
const ( NeverDerefAliases DerefAliases = 0 DerefInSearching DerefAliases = 1 DerefFindingBaseObj DerefAliases = 2 DerefAlways DerefAliases = 3 )
func (DerefAliases) String ¶
func (d DerefAliases) String() string
type EqualityMatch ¶
type EqualityMatch AttributeValueAssertion
func (*EqualityMatch) Encode ¶
func (f *EqualityMatch) Encode() (*Packet, error)
func (*EqualityMatch) String ¶
func (f *EqualityMatch) String() string
type ErrFilterSyntaxError ¶
func (*ErrFilterSyntaxError) Error ¶
func (e *ErrFilterSyntaxError) Error() string
type ExtendedRequest ¶
func (*ExtendedRequest) WritePackets ¶
func (r *ExtendedRequest) WritePackets(w io.Writer, msgID int) error
type ExtendedResponse ¶
type ExtendedResponse struct { BaseResponse Name string Value []byte }
func (*ExtendedResponse) WritePackets ¶
func (r *ExtendedResponse) WritePackets(w io.Writer, msgID int) error
type ExtensibleMatch ¶
type Filter ¶
func ParseFilter ¶
type GreaterOrEqual ¶
type GreaterOrEqual AttributeValueAssertion
func (*GreaterOrEqual) Encode ¶
func (f *GreaterOrEqual) Encode() (*Packet, error)
func (*GreaterOrEqual) String ¶
func (f *GreaterOrEqual) String() string
type InvalidBEREncodingError ¶
type InvalidBEREncodingError string
func (InvalidBEREncodingError) Error ¶
func (e InvalidBEREncodingError) Error() string
type LessOrEqual ¶
type LessOrEqual AttributeValueAssertion
func (*LessOrEqual) Encode ¶
func (f *LessOrEqual) Encode() (*Packet, error)
func (*LessOrEqual) String ¶
func (f *LessOrEqual) String() string
type ModifyDNRequest ¶
type ModifyDNResponse ¶
type ModifyDNResponse struct {
BaseResponse
}
func (*ModifyDNResponse) WritePackets ¶
func (r *ModifyDNResponse) WritePackets(w io.Writer, msgID int) error
type ModifyRequest ¶
func (*ModifyRequest) WritePackets ¶
func (r *ModifyRequest) WritePackets(w io.Writer, msgID int) error
type ModifyResponse ¶
type ModifyResponse struct {
BaseResponse
}
func (*ModifyResponse) WritePackets ¶
func (r *ModifyResponse) WritePackets(w io.Writer, msgID int) error
type Packet ¶
type Packet struct { Class Class Primitive bool // true=primitive, false=constructed Tag int Value interface{} Items []*Packet }
func NewRequestPacket ¶
func NewResponsePacket ¶
type PasswordModifyRequest ¶
type PasswordModifyResponse ¶
type PasswordModifyResponse struct {
GenPassword []byte // [0] OCTET STRING OPTIONAL
}
type ProtocolError ¶
type ProtocolError string
func (ProtocolError) Error ¶
func (e ProtocolError) Error() string
type ResultCode ¶
type ResultCode byte
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 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 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 )
func (ResultCode) String ¶
func (c ResultCode) String() string
type SearchRequest ¶
type SearchRequest struct { BaseDN string Scope Scope DerefAliases DerefAliases SizeLimit int TimeLimit int TypesOnly bool Filter Filter Attributes map[string]bool }
func (*SearchRequest) WritePackets ¶
func (r *SearchRequest) WritePackets(w io.Writer, msgID int) error
type SearchResponse ¶
type SearchResponse struct { BaseResponse Results []*SearchResult }
func (*SearchResponse) WritePackets ¶
func (r *SearchResponse) WritePackets(w io.Writer, msgID int) error
type SearchResult ¶
type Server ¶
type State ¶
type State interface{}
State is passed created by and passed back to a server backend to provide state for a client connection.
type Substrings ¶
func (*Substrings) Encode ¶
func (f *Substrings) Encode() (*Packet, error)
func (*Substrings) String ¶
func (s *Substrings) String() string
type UnsupportedRequestTagError ¶
type UnsupportedRequestTagError int
func (UnsupportedRequestTagError) Error ¶
func (e UnsupportedRequestTagError) Error() string