Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertString(octetString ...string) ([]string, error)
- func SIDBytes(revision uint8, identifierAuthority uint16) ([]byte, error)
- func SIDBytesToString(b []byte) (string, error)
- func TestEncodeString(t *testing.T, tag ber.Tag, s string, opt ...Option) string
- func TestWithDebug(t *testing.T) bool
- type AddMessage
- type Attribute
- type AuthChoice
- type BindResponse
- type Change
- type Control
- type ControlBeheraPasswordPolicy
- func (c *ControlBeheraPasswordPolicy) Encode() *ber.Packet
- func (c *ControlBeheraPasswordPolicy) ErrorCode() (int, string)
- func (c *ControlBeheraPasswordPolicy) Expire() int
- func (c *ControlBeheraPasswordPolicy) GetControlType() string
- func (c *ControlBeheraPasswordPolicy) Grace() int
- func (c *ControlBeheraPasswordPolicy) String() string
- type ControlManageDsaIT
- type ControlMicrosoftNotification
- type ControlMicrosoftServerLinkTTL
- type ControlMicrosoftShowDeleted
- type ControlPaging
- type ControlString
- type ControlVChuPasswordMustChange
- type ControlVChuPasswordWarning
- type DeleteMessage
- type Entry
- type EntryAttribute
- type ExtendedOperationMessage
- type ExtendedOperationName
- type ExtendedResponse
- type GeneralResponse
- type HandlerFunc
- type Message
- type ModifyMessage
- type ModifyResponse
- type Mux
- func (m *Mux) Add(addFn HandlerFunc, opt ...Option) error
- func (m *Mux) Bind(bindFn HandlerFunc, opt ...Option) error
- func (m *Mux) DefaultRoute(noRouteFN HandlerFunc, opt ...Option) error
- func (m *Mux) Delete(modifyFn HandlerFunc, opt ...Option) error
- func (m *Mux) ExtendedOperation(operationFn HandlerFunc, exName ExtendedOperationName, opt ...Option) error
- func (m *Mux) Modify(modifyFn HandlerFunc, opt ...Option) error
- func (m *Mux) Search(searchFn HandlerFunc, opt ...Option) error
- func (m *Mux) Unbind(bindFn HandlerFunc, opt ...Option) error
- type OnCloseHandler
- type Option
- func WithApplicationCode(applicationCode int) Option
- func WithAttributes(attributes map[string][]string) Option
- func WithBaseDN(dn string) Option
- func WithControlValue(value string) Option
- func WithCriticality(criticality bool) Option
- func WithDescription(desc string) Option
- func WithDiagnosticMessage(msg string) Option
- func WithDisablePanicRecovery() Option
- func WithErrorCode(code uint) Option
- func WithFilter(filter string) Option
- func WithGraceAuthNsRemaining(remaining uint) Option
- func WithLabel(l string) Option
- func WithLogger(l hclog.Logger) Option
- func WithMatchedDN(dn string) Option
- func WithOnClose(handler OnCloseHandler) Option
- func WithReadTimeout(d time.Duration) Option
- func WithResponseCode(code int) Option
- func WithScope(s Scope) Option
- func WithSecondsBeforeExpiration(seconds uint) Option
- func WithTLSConfig(tc *tls.Config) Option
- func WithWriteTimeout(d time.Duration) Option
- func WithWriter(w io.Writer) Option
- type PartialAttribute
- type Password
- type Request
- func (r *Request) ConnectionID() int
- func (r *Request) GetAddMessage() (*AddMessage, error)
- func (r *Request) GetDeleteMessage() (*DeleteMessage, error)
- func (r *Request) GetModifyMessage() (*ModifyMessage, error)
- func (r *Request) GetSearchMessage() (*SearchMessage, error)
- func (r *Request) GetSimpleBindMessage() (*SimpleBindMessage, error)
- func (r *Request) GetUnbindMessage() (*UnbindMessage, error)
- func (r *Request) NewBindResponse(opt ...Option) *BindResponse
- func (r *Request) NewExtendedResponse(opt ...Option) *ExtendedResponse
- func (r *Request) NewModifyResponse(opt ...Option) *ModifyResponse
- func (r *Request) NewResponse(opt ...Option) *GeneralResponse
- func (r *Request) NewSearchDoneResponse(opt ...Option) *SearchResponseDone
- func (r *Request) NewSearchResponseEntry(entryDN string, opt ...Option) *SearchResponseEntry
- func (r *Request) StartTLS(tlsconfig *tls.Config) error
- type Response
- type ResponseWriter
- type Scope
- type SearchMessage
- type SearchResponseDone
- type SearchResponseEntry
- type Server
- type SimpleBindMessage
- type UnbindMessage
Constants ¶
const ( ResultSuccess = 0 ResultOperationsError = 1 ResultProtocolError = 2 ResultTimeLimitExceeded = 3 ResultSizeLimitExceeded = 4 ResultCompareFalse = 5 ResultCompareTrue = 6 ResultAuthMethodNotSupported = 7 ResultStrongAuthRequired = 8 ResultReferral = 10 ResultAdminLimitExceeded = 11 ResultConfidentialityRequired = 13 ResultSaslBindInProgress = 14 ResultNoSuchAttribute = 16 ResultUndefinedAttributeType = 17 ResultInappropriateMatching = 18 ResultConstraintViolation = 19 ResultAttributeOrValueExists = 20 ResultInvalidAttributeSyntax = 21 ResultNoSuchObject = 32 ResultAliasProblem = 33 ResultInvalidDNSyntax = 34 ResultIsLeaf = 35 ResultAliasDereferencingProblem = 36 ResultInappropriateAuthentication = 48 ResultInvalidCredentials = 49 ResultInsufficientAccessRights = 50 ResultBusy = 51 ResultUnwillingToPerform = 53 ResultLoopDetect = 54 ResultSortControlMissing = 60 ResultOffsetRangeError = 61 ResultNamingViolation = 64 ResultObjectClassViolation = 65 ResultNotAllowedOnNonLeaf = 66 ResultNotAllowedOnRDN = 67 ResultEntryAlreadyExists = 68 ResultObjectClassModsProhibited = 69 ResultResultsTooLarge = 70 ResultAffectsMultipleDSAs = 71 ResultVirtualListViewErrorOrControlError = 76 ResultOther = 80 ResultServerDown = 81 ResultLocalError = 82 ResultEncodingError = 83 ResultDecodingError = 84 ResultTimeout = 85 ResultAuthUnknown = 86 ResultFilterError = 87 ResultUserCanceled = 88 ResultParamError = 89 ResultNoMemory = 90 ResultConnectError = 91 ResultNotSupported = 92 ResultControlNotFound = 93 ResultNoResultsReturned = 94 ResultMoreResultsToReturn = 95 ResultClientLoop = 96 ResultReferralLimitExceeded = 97 ResultInvalidResponse = 100 ResultAmbiguousResponse = 101 ResultTLSNotSupported = 112 ResultIntermediateResponse = 113 ResultUnknownType = 114 ResultCanceled = 118 ResultNoSuchOperation = 119 ResultTooLate = 120 ResultCannotCancel = 121 ResultAssertionFailed = 122 ResultAuthorizationDenied = 123 ResultSyncRefreshRequired = 4096 )
ldap result codes
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 )
ldap application codes
const ( // ControlTypePaging - https://www.ietf.org/rfc/rfc2696.txt ControlTypePaging = "1.2.840.113556.1.4.319" // ControlTypeBeheraPasswordPolicy - https://tools.ietf.org/html/draft-behera-ldap-password-policy-10 ControlTypeBeheraPasswordPolicy = "1.3.6.1.4.1.42.2.27.8.5.1" // ControlTypeVChuPasswordMustChange - https://tools.ietf.org/html/draft-vchu-ldap-pwd-policy-00 ControlTypeVChuPasswordMustChange = "2.16.840.1.113730.3.4.4" // ControlTypeVChuPasswordWarning - https://tools.ietf.org/html/draft-vchu-ldap-pwd-policy-00 ControlTypeVChuPasswordWarning = "2.16.840.1.113730.3.4.5" // ControlTypeManageDsaIT - https://tools.ietf.org/html/rfc3296 ControlTypeManageDsaIT = "2.16.840.1.113730.3.4.2" // ControlTypeWhoAmI - https://tools.ietf.org/html/rfc4532 ControlTypeWhoAmI = "1.3.6.1.4.1.4203.1.11.3" // ControlTypeMicrosoftNotification - https://msdn.microsoft.com/en-us/library/aa366983(v=vs.85).aspx ControlTypeMicrosoftNotification = "1.2.840.113556.1.4.528" // ControlTypeMicrosoftShowDeleted - https://msdn.microsoft.com/en-us/library/aa366989(v=vs.85).aspx ControlTypeMicrosoftShowDeleted = "1.2.840.113556.1.4.417" // ControlTypeMicrosoftServerLinkTTL - https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/f4f523a8-abc0-4b3a-a471-6b2fef135481?redirectedfrom=MSDN ControlTypeMicrosoftServerLinkTTL = "1.2.840.113556.1.4.2309" )
const ( BeheraPasswordExpired = 0 BeheraAccountLocked = 1 BeheraChangeAfterReset = 2 BeheraPasswordModNotAllowed = 3 BeheraMustSupplyOldPassword = 4 BeheraInsufficientPasswordQuality = 5 BeheraPasswordTooShort = 6 BeheraPasswordTooYoung = 7 BeheraPasswordInHistory = 8 )
Ldap Behera Password Policy Draft 10 (https://tools.ietf.org/html/draft-behera-ldap-password-policy-10)
const ( AddAttribute = 0 DeleteAttribute = 1 ReplaceAttribute = 2 IncrementAttribute = 3 // (https://tools.ietf.org/html/rfc4525) )
Change operation choices
Variables ¶
var ( // ErrUnknown is an unknown/undefined error ErrUnknown = errors.New("unknown") // ErrInvalidParameter is an invalid parameter error ErrInvalidParameter = errors.New("invalid parameter") // ErrInvalidState is an invalid state error ErrInvalidState = errors.New("invalid state") // ErrInternal is an internal error ErrInternal = errors.New("internal error") )
var ApplicationCodeMap = 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", }
ApplicationCodeMap contains human readable descriptions of ldap application codes
var BeheraPasswordPolicyErrorMap = map[int8]string{ BeheraPasswordExpired: "Password expired", BeheraAccountLocked: "Account locked", BeheraChangeAfterReset: "Password must be changed", BeheraPasswordModNotAllowed: "Policy prevents password modification", BeheraMustSupplyOldPassword: "Policy requires old password in order to change password", BeheraInsufficientPasswordQuality: "Password fails quality checks", BeheraPasswordTooShort: "Password is too short for policy", BeheraPasswordTooYoung: "Password has been changed too recently", BeheraPasswordInHistory: "New password is in list of old passwords", }
BeheraPasswordPolicyErrorMap contains human readable descriptions of Behera Password Policy error codes
var ControlTypeMap = map[string]string{ ControlTypePaging: "Paging", ControlTypeBeheraPasswordPolicy: "Password Policy - Behera Draft", ControlTypeManageDsaIT: "Manage DSA IT", ControlTypeMicrosoftNotification: "Change Notification - Microsoft", ControlTypeMicrosoftShowDeleted: "Show Deleted Objects - Microsoft", ControlTypeMicrosoftServerLinkTTL: "Return TTL-DNs for link values with associated expiry times - Microsoft", }
ControlTypeMap maps controls to text descriptions
var ResultCodeMap = map[uint16]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", ResultIsLeaf: "Is Leaf", 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", ResultSortControlMissing: "Sort Control Missing", ResultOffsetRangeError: "Result Offset Range Error", ResultNamingViolation: "Naming Violation", ResultObjectClassViolation: "Object Class Violation", ResultResultsTooLarge: "Results Too Large", ResultNotAllowedOnNonLeaf: "Not Allowed On Non Leaf", ResultNotAllowedOnRDN: "Not Allowed On RDN", ResultEntryAlreadyExists: "Entry Already Exists", ResultObjectClassModsProhibited: "Object Class Mods Prohibited", ResultAffectsMultipleDSAs: "Affects Multiple DSAs", ResultVirtualListViewErrorOrControlError: "Failed because of a problem related to the virtual list view", ResultOther: "Other", ResultServerDown: "Cannot establish a connection", ResultLocalError: "An error occurred", ResultEncodingError: " encountered an error while encoding", ResultDecodingError: " encountered an error while decoding", ResultTimeout: " timeout while waiting for a response from the server", ResultAuthUnknown: "The auth method requested in a bind request is unknown", ResultFilterError: "An error occurred while encoding the given search filter", ResultUserCanceled: "The user canceled the operation", ResultParamError: "An invalid parameter was specified", ResultNoMemory: "Out of memory error", ResultConnectError: "A connection to the server could not be established", ResultNotSupported: "An attempt has been made to use a feature not supported ", ResultControlNotFound: "The controls required to perform the requested operation were not found", ResultNoResultsReturned: "No results were returned from the server", ResultMoreResultsToReturn: "There are more results in the chain of results", ResultClientLoop: "A loop has been detected. For example when following referrals", ResultReferralLimitExceeded: "The referral hop limit has been exceeded", ResultCanceled: "Operation was canceled", ResultNoSuchOperation: "Server has no knowledge of the operation requested for cancellation", ResultTooLate: "Too late to cancel the outstanding operation", ResultCannotCancel: "The identified operation does not support cancellation or the cancel operation cannot be performed", ResultAssertionFailed: "An assertion control given in the operation evaluated to false causing the operation to not be performed", ResultSyncRefreshRequired: "Refresh Required", ResultInvalidResponse: "Invalid Response", ResultAmbiguousResponse: "Ambiguous Response", ResultTLSNotSupported: "Tls Not Supported", ResultIntermediateResponse: "Intermediate Response", ResultUnknownType: "Unknown Type", ResultAuthorizationDenied: "Authorization Denied", }
ResultCodeMap contains string descriptions for ldap result codes
Functions ¶
func ConvertString ¶ added in v0.1.3
ConvertString will convert an ASN1 BER Octet string into a "native" go string. Support ber string encoding types: OctetString, GeneralString and all other types will return an error.
func SIDBytesToString ¶
SIDBytesToString will convert SID bytes to a string
func TestEncodeString ¶ added in v0.1.3
func TestWithDebug ¶
TestWithDebug specifies that the test should be run under "debug" mode
Types ¶
type AddMessage ¶
type AddMessage struct { // DN identifies the entry being added DN string // Attributes list the attributes of the new entry Attributes []Attribute // Controls hold optional controls to send with the request Controls []Control // contains filtered or unexported fields }
AddMessage is an add request message
type Attribute ¶
type Attribute struct { // Type is the name of the LDAP attribute Type string // Vals are the LDAP attribute values Vals []string }
Attribute represents an LDAP attribute within AddMessage
type AuthChoice ¶
type AuthChoice string
AuthChoice defines the authentication choice for bind message
const SimpleAuthChoice AuthChoice = "simple"
SimpleAuthChoice specifies a simple user/password authentication choice for the bind message
type BindResponse ¶
type BindResponse struct {
// contains filtered or unexported fields
}
BindResponse represents the response to a bind request
func (*BindResponse) SetControls ¶
func (r *BindResponse) SetControls(controls ...Control)
SetControls for bind response
func (BindResponse) SetDiagnosticMessage ¶
func (l BindResponse) SetDiagnosticMessage(msg string)
SetDiagnosticMessage sets the optional diagnostic message for a response.
func (BindResponse) SetMatchedDN ¶
func (l BindResponse) SetMatchedDN(dn string)
SetMatchedDN sets the optional matched DN for a response.
func (BindResponse) SetResultCode ¶
func (l BindResponse) SetResultCode(code int)
SetResultCode the result code for a response.
type Change ¶
type Change struct { // Operation is the type of change to be made Operation int64 // Modification is the attribute to be modified Modification PartialAttribute }
Change for a ModifyMessage as defined in https://tools.ietf.org/html/rfc4511
type Control ¶
type Control interface { // GetControlType returns the OID GetControlType() string // Encode returns the ber packet representation Encode() *ber.Packet // String returns a human-readable description String() string }
Control defines a common interface for all ldap controls
type ControlBeheraPasswordPolicy ¶
type ControlBeheraPasswordPolicy struct {
// contains filtered or unexported fields
}
ControlBeheraPasswordPolicy implements the control described in https://tools.ietf.org/html/draft-behera-ldap-password-policy-10
func NewControlBeheraPasswordPolicy ¶
func NewControlBeheraPasswordPolicy(opt ...Option) (*ControlBeheraPasswordPolicy, error)
NewControlBeheraPasswordPolicy returns a ControlBeheraPasswordPolicy. Options supported: WithExpire, WithGrace, WithErrorCode
func (*ControlBeheraPasswordPolicy) Encode ¶
func (c *ControlBeheraPasswordPolicy) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlBeheraPasswordPolicy) ErrorCode ¶
func (c *ControlBeheraPasswordPolicy) ErrorCode() (int, string)
ErrorCode is the error code and a human readable string. A value of -1 and empty string indicates it hasn't been set.
func (*ControlBeheraPasswordPolicy) Expire ¶
func (c *ControlBeheraPasswordPolicy) Expire() int
Expire contains the number of seconds before a password will expire. A value of -1 indicates it hasn't been set.
func (*ControlBeheraPasswordPolicy) GetControlType ¶
func (c *ControlBeheraPasswordPolicy) GetControlType() string
GetControlType returns the OID
func (*ControlBeheraPasswordPolicy) Grace ¶
func (c *ControlBeheraPasswordPolicy) Grace() int
Grace returns the remaining number of times a user will be allowed to authenticate with an expired password. A value of -1 indicates it hasn't been set.
func (*ControlBeheraPasswordPolicy) String ¶
func (c *ControlBeheraPasswordPolicy) String() string
String returns a human-readable description
type ControlManageDsaIT ¶
type ControlManageDsaIT struct { // Criticality indicates if this control is required Criticality bool }
ControlManageDsaIT implements the control described in https://tools.ietf.org/html/rfc3296
func NewControlManageDsaIT ¶
func NewControlManageDsaIT(opt ...Option) (*ControlManageDsaIT, error)
NewControlManageDsaIT returns a ControlManageDsaIT control. Supported options: WithCriticality
func (*ControlManageDsaIT) Encode ¶
func (c *ControlManageDsaIT) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlManageDsaIT) GetControlType ¶
func (c *ControlManageDsaIT) GetControlType() string
GetControlType returns the OID
func (*ControlManageDsaIT) String ¶
func (c *ControlManageDsaIT) String() string
String returns a human-readable description
type ControlMicrosoftNotification ¶
type ControlMicrosoftNotification struct{}
ControlMicrosoftNotification implements the control described in https://msdn.microsoft.com/en-us/library/aa366983(v=vs.85).aspx
func NewControlMicrosoftNotification ¶
func NewControlMicrosoftNotification(_ ...Option) (*ControlMicrosoftNotification, error)
NewControlMicrosoftNotification returns a ControlMicrosoftNotification control. No options are currently supported.
func (*ControlMicrosoftNotification) Encode ¶
func (c *ControlMicrosoftNotification) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlMicrosoftNotification) GetControlType ¶
func (c *ControlMicrosoftNotification) GetControlType() string
GetControlType returns the OID
func (*ControlMicrosoftNotification) String ¶
func (c *ControlMicrosoftNotification) String() string
String returns a human-readable description
type ControlMicrosoftServerLinkTTL ¶
type ControlMicrosoftServerLinkTTL struct{}
ControlMicrosoftServerLinkTTL implements the control described in https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/f4f523a8-abc0-4b3a-a471-6b2fef135481?redirectedfrom=MSDN
func NewControlMicrosoftServerLinkTTL ¶
func NewControlMicrosoftServerLinkTTL(_ ...Option) (*ControlMicrosoftServerLinkTTL, error)
NewControlMicrosoftServerLinkTTL returns a ControlMicrosoftServerLinkTTL control. No options are currently supported.
func (*ControlMicrosoftServerLinkTTL) Encode ¶
func (c *ControlMicrosoftServerLinkTTL) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlMicrosoftServerLinkTTL) GetControlType ¶
func (c *ControlMicrosoftServerLinkTTL) GetControlType() string
GetControlType returns the OID
func (*ControlMicrosoftServerLinkTTL) String ¶
func (c *ControlMicrosoftServerLinkTTL) String() string
String returns a human-readable description
type ControlMicrosoftShowDeleted ¶
type ControlMicrosoftShowDeleted struct{}
ControlMicrosoftShowDeleted implements the control described in https://msdn.microsoft.com/en-us/library/aa366989(v=vs.85).aspx
func NewControlMicrosoftShowDeleted ¶
func NewControlMicrosoftShowDeleted(_ ...Option) (*ControlMicrosoftShowDeleted, error)
NewControlMicrosoftShowDeleted returns a ControlMicrosoftShowDeleted control. No options are currently supported.
func (*ControlMicrosoftShowDeleted) Encode ¶
func (c *ControlMicrosoftShowDeleted) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlMicrosoftShowDeleted) GetControlType ¶
func (c *ControlMicrosoftShowDeleted) GetControlType() string
GetControlType returns the OID
func (*ControlMicrosoftShowDeleted) String ¶
func (c *ControlMicrosoftShowDeleted) String() string
String returns a human-readable description
type ControlPaging ¶
type ControlPaging struct { // PagingSize indicates the page size PagingSize uint32 // Cookie is an opaque value returned by the server to track a paging cursor Cookie []byte }
ControlPaging implements the paging control described in https://www.ietf.org/rfc/rfc2696.txt
func NewControlPaging ¶
func NewControlPaging(pagingSize uint32, _ ...Option) (*ControlPaging, error)
NewControlPaging returns a paging control
func (*ControlPaging) Encode ¶
func (c *ControlPaging) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlPaging) GetControlType ¶
func (c *ControlPaging) GetControlType() string
GetControlType returns the OID
func (*ControlPaging) SetCookie ¶
func (c *ControlPaging) SetCookie(cookie []byte)
SetCookie stores the given cookie in the paging control
func (*ControlPaging) String ¶
func (c *ControlPaging) String() string
String returns a human-readable description
type ControlString ¶
ControlString implements the Control interface for simple controls
func NewControlString ¶
func NewControlString(controlType string, opt ...Option) (*ControlString, error)
NewControlString returns a generic control. Options supported: WithCriticality and WithControlValue
func (*ControlString) Encode ¶
func (c *ControlString) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlString) GetControlType ¶
func (c *ControlString) GetControlType() string
GetControlType returns the OID
func (*ControlString) String ¶
func (c *ControlString) String() string
String returns a human-readable description
type ControlVChuPasswordMustChange ¶
type ControlVChuPasswordMustChange struct { // MustChange indicates if the password is required to be changed MustChange bool }
ControlVChuPasswordMustChange implements the control described in https://tools.ietf.org/html/draft-vchu-ldap-pwd-policy-00
func (*ControlVChuPasswordMustChange) Encode ¶
func (c *ControlVChuPasswordMustChange) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlVChuPasswordMustChange) GetControlType ¶
func (c *ControlVChuPasswordMustChange) GetControlType() string
GetControlType returns the OID
func (*ControlVChuPasswordMustChange) String ¶
func (c *ControlVChuPasswordMustChange) String() string
String returns a human-readable description
type ControlVChuPasswordWarning ¶
type ControlVChuPasswordWarning struct { // Expire indicates the time in seconds until the password expires Expire int64 }
ControlVChuPasswordWarning implements the control described in https://tools.ietf.org/html/draft-vchu-ldap-pwd-policy-00
func (*ControlVChuPasswordWarning) Encode ¶
func (c *ControlVChuPasswordWarning) Encode() *ber.Packet
Encode returns the ber packet representation
func (*ControlVChuPasswordWarning) GetControlType ¶
func (c *ControlVChuPasswordWarning) GetControlType() string
GetControlType returns the OID
func (*ControlVChuPasswordWarning) String ¶
func (c *ControlVChuPasswordWarning) String() string
String returns a human-readable description
type DeleteMessage ¶
type DeleteMessage struct { // DN identifies the entry being added DN string // Controls hold optional controls to send with the request Controls []Control // contains filtered or unexported fields }
DeleteMessage is an delete request message
type Entry ¶
type Entry struct { // DN is the distinguished name of the entry DN string // Attributes are the returned attributes for the entry Attributes []*EntryAttribute }
Entry represents an ldap entry
func NewEntry ¶
NewEntry returns an Entry object with the specified distinguished name and attribute key-value pairs. The map of attributes is accessed in alphabetical order of the keys in order to ensure that, for the same input map of attributes, the output entry will contain the same order of attributes
func (*Entry) GetAttributeValues ¶
GetAttributeValues returns the values for the named attribute, or an empty list
func (*Entry) PrettyPrint ¶
PrettyPrint outputs a human-readable description indenting. Supported options: WithWriter
type EntryAttribute ¶
type EntryAttribute struct { // Name is the name of the attribute Name string // Values contain the string values of the attribute Values []string // ByteValues contain the raw values of the attribute ByteValues [][]byte }
EntryAttribute holds a single attribute
func NewEntryAttribute ¶
func NewEntryAttribute(name string, values []string) *EntryAttribute
NewEntryAttribute returns a new EntryAttribute with the desired key-value pair
func (*EntryAttribute) AddValue ¶
func (e *EntryAttribute) AddValue(value ...string)
AddValue to an existing EntryAttribute
func (*EntryAttribute) PrettyPrint ¶
func (e *EntryAttribute) PrettyPrint(indent int, opt ...Option)
PrettyPrint outputs a human-readable description with indenting. Supported options: WithWriter
type ExtendedOperationMessage ¶
type ExtendedOperationMessage struct { // Name of the extended operation Name ExtendedOperationName // Value of the extended operation Value string // contains filtered or unexported fields }
ExtendedOperationMessage is an extended operation request message
type ExtendedOperationName ¶
type ExtendedOperationName string
ExtendedOperationName is an extended operation request/response name
const ( ExtendedOperationDisconnection ExtendedOperationName = "1.3.6.1.4.1.1466.2003" ExtendedOperationCancel ExtendedOperationName = "1.3.6.1.1.8" ExtendedOperationStartTLS ExtendedOperationName = "1.3.6.1.4.1.1466.20037" ExtendedOperationWhoAmI ExtendedOperationName = "1.3.6.1.4.1.4203.1.11.3" ExtendedOperationGetConnectionID ExtendedOperationName = "1.3.6.1.4.1.26027.1.6.2" ExtendedOperationPasswordModify ExtendedOperationName = "1.3.6.1.4.1.4203.1.11.1" ExtendedOperationUnknown ExtendedOperationName = "Unknown" )
Extended operation response/request names
type ExtendedResponse ¶
type ExtendedResponse struct {
// contains filtered or unexported fields
}
ExtendedResponse represents a response to an extended operation request
func (ExtendedResponse) SetDiagnosticMessage ¶
func (l ExtendedResponse) SetDiagnosticMessage(msg string)
SetDiagnosticMessage sets the optional diagnostic message for a response.
func (ExtendedResponse) SetMatchedDN ¶
func (l ExtendedResponse) SetMatchedDN(dn string)
SetMatchedDN sets the optional matched DN for a response.
func (*ExtendedResponse) SetResponseName ¶
func (r *ExtendedResponse) SetResponseName(n ExtendedOperationName)
SetResponseName will set the response name for the extended operation response.
func (ExtendedResponse) SetResultCode ¶
func (l ExtendedResponse) SetResultCode(code int)
SetResultCode the result code for a response.
type GeneralResponse ¶
type GeneralResponse struct {
// contains filtered or unexported fields
}
GeneralResponse represents a general response (non-specific to a request).
func (GeneralResponse) SetDiagnosticMessage ¶
func (l GeneralResponse) SetDiagnosticMessage(msg string)
SetDiagnosticMessage sets the optional diagnostic message for a response.
func (GeneralResponse) SetMatchedDN ¶
func (l GeneralResponse) SetMatchedDN(dn string)
SetMatchedDN sets the optional matched DN for a response.
func (GeneralResponse) SetResultCode ¶
func (l GeneralResponse) SetResultCode(code int)
SetResultCode the result code for a response.
type HandlerFunc ¶
type HandlerFunc func(*ResponseWriter, *Request)
HandlerFunc defines a function for handling an LDAP request.
type Message ¶
type Message interface { // GetID returns the message ID GetID() int64 }
Message defines a common interface for all messages
type ModifyMessage ¶
type ModifyMessage struct { DN string Changes []Change Controls []Control // contains filtered or unexported fields }
ModifyMessage as defined in https://tools.ietf.org/html/rfc4511
type ModifyResponse ¶
type ModifyResponse struct {
*GeneralResponse
}
ModifyResponse is a response to a modify request.
func (ModifyResponse) SetDiagnosticMessage ¶
func (l ModifyResponse) SetDiagnosticMessage(msg string)
SetDiagnosticMessage sets the optional diagnostic message for a response.
func (ModifyResponse) SetMatchedDN ¶
func (l ModifyResponse) SetMatchedDN(dn string)
SetMatchedDN sets the optional matched DN for a response.
func (ModifyResponse) SetResultCode ¶
func (l ModifyResponse) SetResultCode(code int)
SetResultCode the result code for a response.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is an ldap request multiplexer. It matches the inbound request against a list of registered route handlers. Routes are matched in the order they're added and only one route is called per request.
func (*Mux) Add ¶
func (m *Mux) Add(addFn HandlerFunc, opt ...Option) error
Add will register a handler for add operation requests. Options supported: WithLabel
func (*Mux) Bind ¶
func (m *Mux) Bind(bindFn HandlerFunc, opt ...Option) error
Bind will register a handler for bind requests. Options supported: WithLabel
func (*Mux) DefaultRoute ¶
func (m *Mux) DefaultRoute(noRouteFN HandlerFunc, opt ...Option) error
DefaultRoute will register a default handler requests which have no other registered handler.
func (*Mux) Delete ¶
func (m *Mux) Delete(modifyFn HandlerFunc, opt ...Option) error
Delete will register a handler for delete operation requests. Options supported: WithLabel
func (*Mux) ExtendedOperation ¶
func (m *Mux) ExtendedOperation(operationFn HandlerFunc, exName ExtendedOperationName, opt ...Option) error
ExtendedOperation will register a handler for extended operation requests. Options supported: WithLabel
func (*Mux) Modify ¶
func (m *Mux) Modify(modifyFn HandlerFunc, opt ...Option) error
Modify will register a handler for modify operation requests. Options supported: WithLabel
func (*Mux) Search ¶
func (m *Mux) Search(searchFn HandlerFunc, opt ...Option) error
Search will register a handler for search requests. Options supported: WithLabel, WithBaseDN, WithScope
func (*Mux) Unbind ¶ added in v0.1.1
func (m *Mux) Unbind(bindFn HandlerFunc, opt ...Option) error
Unbind will register a handler for unbind requests and override the default unbind handler. Registering an unbind handler is optional and regardless of whether or not an unbind route is defined the server will stop serving requests for a connection after an unbind request is received. Options supported: WithLabel
type OnCloseHandler ¶ added in v0.1.2
type OnCloseHandler func(connectionID int)
OnCloseHandler defines a function for a "on close" callback handler. See: NewServer(...) and WithOnClose(...) option for more information
type Option ¶
type Option func(interface{})
Option defines a common functional options type which can be used in a variadic parameter pattern.
func WithApplicationCode ¶
WithApplicationCode specifies the ldap application code. For a list of valid codes for a list of supported application codes see: https://github.com/jimlambrt/gldap/blob/8f171b8eb659c76019719382c4daf519dd1281e6/codes.go#L159
func WithAttributes ¶
WithAttributes specifies optional attributes for a response entry
func WithBaseDN ¶
WithBaseDN specifies an optional base DN to associate with a Search route
func WithControlValue ¶
WithControlValue specifies the control value
func WithCriticality ¶
WithCriticality specifies the criticality
func WithDescription ¶ added in v0.1.3
WithDescription allows you to specify an optional description.
func WithDiagnosticMessage ¶
WithDiagnosticMessage provides an optional diagnostic message for the response.
func WithDisablePanicRecovery ¶
func WithDisablePanicRecovery() Option
WithDisablePanicRecovery will disable recovery from panics which occur when handling a request. This is helpful for debugging since you'll get the panic's callstack.
func WithFilter ¶
WithFilter specifies an optional filter to associate with a Search route
func WithGraceAuthNsRemaining ¶
WithGraceAuthNsRemaining specifies the number of grace authentication remaining.
func WithMatchedDN ¶
WithMatchedDN provides an optional match DN for the response.
func WithOnClose ¶ added in v0.1.2
func WithOnClose(handler OnCloseHandler) Option
WithOnClose defines a OnCloseHandler that the server will use as a callback every time a connection to the server is closed. This allows callers to clean up resources for closed connections (using their ID to determine which one to clean up)
func WithReadTimeout ¶
WithReadTimeout will set a read time out per connection
func WithResponseCode ¶
WithResponseCode specifies the ldap response code. For a list of valid codes see: https://github.com/go-ldap/ldap/blob/13008e4c5260d08625b65eb1f172ae909152b751/v3/error.go#L11
func WithSecondsBeforeExpiration ¶
WithSecondsBeforeExpiration specifies the number of seconds before a password will expire
func WithTLSConfig ¶
WithTLSConfig provides an optional tls.Config
func WithWriteTimeout ¶
WithWriteTimeout will set a write timeout per connection
func WithWriter ¶
WithWriter allows you to specify an optional writer.
type PartialAttribute ¶
type PartialAttribute struct { // Type is the type of the partial attribute Type string // Vals are the values of the partial attribute Vals []string }
PartialAttribute for a ModifyMessage as defined in https://tools.ietf.org/html/rfc4511
type Request ¶
type Request struct { // ID is the request number for a specific connection. Every connection has // its own request counter which starts at 1. ID int // contains filtered or unexported fields }
Request represents an ldap request
func (*Request) ConnectionID ¶ added in v0.1.2
ConnectionID returns the request's connection ID which enables you to know "who" (i.e. which connection) made a request. Using the connection ID you can do things like ensure a connection performing a search operation has successfully authenticated (a.k.a. performed a successful bind operation).
func (*Request) GetAddMessage ¶
func (r *Request) GetAddMessage() (*AddMessage, error)
GetAddMessage retrieves the AddMessage from the request, which allows you handle the request based on the message attributes.
func (*Request) GetDeleteMessage ¶
func (r *Request) GetDeleteMessage() (*DeleteMessage, error)
GetDeleteMessage retrieves the DeleteMessage from the request, which allows you handle the request based on the message attributes.
func (*Request) GetModifyMessage ¶
func (r *Request) GetModifyMessage() (*ModifyMessage, error)
GetModifyMessage retrieves the ModifyMessage from the request, which allows you handle the request based on the message attributes.
func (*Request) GetSearchMessage ¶
func (r *Request) GetSearchMessage() (*SearchMessage, error)
GetSearchMessage retrieves the SearchMessage from the request, which allows you handle the request based on the message attributes.
func (*Request) GetSimpleBindMessage ¶
func (r *Request) GetSimpleBindMessage() (*SimpleBindMessage, error)
GetSimpleBindMessage retrieves the SimpleBindMessage from the request, which allows you handle the request based on the message attributes.
func (*Request) GetUnbindMessage ¶ added in v0.1.1
func (r *Request) GetUnbindMessage() (*UnbindMessage, error)
GetUnbindMessage retrieves the UnbindMessage from the request, which allows you handle the request based on the message attributes.
func (*Request) NewBindResponse ¶
func (r *Request) NewBindResponse(opt ...Option) *BindResponse
NewBindResponse creates a new bind response. Supported options: WithResponseCode
func (*Request) NewExtendedResponse ¶
func (r *Request) NewExtendedResponse(opt ...Option) *ExtendedResponse
NewExtendedResponse creates a new extended response. Supported options: WithResponseCode
func (*Request) NewModifyResponse ¶
func (r *Request) NewModifyResponse(opt ...Option) *ModifyResponse
NewModifyResponse creates a modify response Supported options: WithResponseCode, WithDiagnosticMessage, WithMatchedDN
func (*Request) NewResponse ¶
func (r *Request) NewResponse(opt ...Option) *GeneralResponse
NewResponse creates a general response (not necessarily to any specific request because you can set WithApplicationCode). Supported options: WithResponseCode, WithApplicationCode, WithDiagnosticMessage, WithMatchedDN
func (*Request) NewSearchDoneResponse ¶
func (r *Request) NewSearchDoneResponse(opt ...Option) *SearchResponseDone
NewSearchDoneResponse creates a new search done response. If there are no results found, then set the response code by adding the option WithResponseCode(ResultNoSuchObject)
Supported options: WithResponseCode
func (*Request) NewSearchResponseEntry ¶
func (r *Request) NewSearchResponseEntry(entryDN string, opt ...Option) *SearchResponseEntry
NewSearchResponseEntry is a search response entry. Supported options: WithAttributes
type Response ¶
type Response interface {
// contains filtered or unexported methods
}
Response represents a response to an ldap request
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
ResponseWriter is an ldap request response writer which is used by a HanderFunc to write responses to client requests.
func (*ResponseWriter) Write ¶
func (rw *ResponseWriter) Write(r Response) error
Write will write the response to the client
type Scope ¶
type Scope int64
Scope represents the scope of a search (see: https://ldap.com/the-ldap-search-operation/)
const ( // BaseObject (often referred to as “base”): Indicates that only the entry // specified as the search base should be considered. None of its // subordinates will be considered. BaseObject Scope = 0 // SingleLevel (often referred to as “one”): Indicates that only the // immediate children of the entry specified as the search base should be // considered. The base entry itself should not be considered, nor any // descendants of the immediate children of the base entry. SingleLevel Scope = 1 // WholeSubtree (often referred to as “sub”): Indicates that the entry // specified as the search base, and all of its subordinates to any depth, // should be considered. Note that in the special case that the search base // DN is the null DN, the root DSE should not be considered in a // wholeSubtree search. WholeSubtree Scope = 2 )
type SearchMessage ¶
type SearchMessage struct { // BaseDN for the request BaseDN string // Scope of the request Scope Scope // DerefAliases for the request DerefAliases int // TimeLimit is the max time in seconds to spend processing TimeLimit int64 // SizeLimit is the max number of results to return SizeLimit int64 // TypesOnly is true if the client only expects type info TypesOnly bool // Filter for the request Filter string // Attributes requested Attributes []string // Controls requested Controls []Control // contains filtered or unexported fields }
SearchMessage is a search request message
type SearchResponseDone ¶
type SearchResponseDone struct {
// contains filtered or unexported fields
}
SearchResponseDone represents that handling a search requests is done.
func (*SearchResponseDone) SetControls ¶
func (r *SearchResponseDone) SetControls(controls ...Control)
SetControls for the search response
func (SearchResponseDone) SetDiagnosticMessage ¶
func (l SearchResponseDone) SetDiagnosticMessage(msg string)
SetDiagnosticMessage sets the optional diagnostic message for a response.
func (SearchResponseDone) SetMatchedDN ¶
func (l SearchResponseDone) SetMatchedDN(dn string)
SetMatchedDN sets the optional matched DN for a response.
func (SearchResponseDone) SetResultCode ¶
func (l SearchResponseDone) SetResultCode(code int)
SetResultCode the result code for a response.
type SearchResponseEntry ¶
type SearchResponseEntry struct {
// contains filtered or unexported fields
}
SearchResponseEntry is an ldap entry that's part of search response.
func (*SearchResponseEntry) AddAttribute ¶
func (r *SearchResponseEntry) AddAttribute(name string, values []string)
AddAttribute will an attributes to the response entry
func (SearchResponseEntry) SetDiagnosticMessage ¶
func (l SearchResponseEntry) SetDiagnosticMessage(msg string)
SetDiagnosticMessage sets the optional diagnostic message for a response.
func (SearchResponseEntry) SetMatchedDN ¶
func (l SearchResponseEntry) SetMatchedDN(dn string)
SetMatchedDN sets the optional matched DN for a response.
func (SearchResponseEntry) SetResultCode ¶
func (l SearchResponseEntry) SetResultCode(code int)
SetResultCode the result code for a response.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an ldap server that you can add a mux (multiplexer) router to and then run it to accept and process requests.
func NewServer ¶
NewServer creates a new ldap server
Options supported: - WithLogger allows you pass a logger with whatever hclog.Level you wish including hclog.Off to turn off all logging - WithReadTimeout will set a read time out per connection - WithWriteTimeout will set a write time out per connection - WithOnClose will define a callback the server will call every time a connection is closed
func (*Server) Router ¶
Router sets the mux (multiplexer) router for matching inbound requests to handlers.
type SimpleBindMessage ¶
type SimpleBindMessage struct { // AuthChoice for the request (SimpleAuthChoice) AuthChoice AuthChoice // UserName for the bind request UserName string // Password for the bind request Password Password // Controls are optional controls for the bind request Controls []Control // contains filtered or unexported fields }
SimpleBindMessage is a simple bind request message
type UnbindMessage ¶ added in v0.1.1
type UnbindMessage struct {
// contains filtered or unexported fields
}
UnbindMessage is an unbind request message