Documentation ¶
Overview ¶
Package ldap provides basic LDAP v3 functionality.
Index ¶
- Constants
- Variables
- func CompileFilter(filter string) (*ber.Packet, error)
- func DebugBinaryFile(fileName string) error
- func DecompileFilter(packet *ber.Packet) (ret string, err error)
- func EscapeFilter(filter string) string
- func NewError(resultCode uint8, err error) error
- type AttributeTypeAndValue
- type Conn
- func (l *Conn) Bind(username, password string) error
- func (l *Conn) Close()
- func (l *Conn) Compare(dn, attribute, value string) (bool, error)
- func (l *Conn) Modify(modifyRequest *ModifyRequest) error
- func (l *Conn) PasswordModify(passwordModifyRequest *PasswordModifyRequest) (*PasswordModifyResult, error)
- func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error)
- func (l *Conn) SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error)
- func (l *Conn) SimpleBind(simpleBindRequest *SimpleBindRequest) (*SimpleBindResult, error)
- func (l *Conn) Start()
- func (l *Conn) StartTLS(config *tls.Config) error
- type Control
- type ControlBeheraPasswordPolicy
- type ControlPaging
- type ControlString
- type ControlVChuPasswordMustChange
- type ControlVChuPasswordWarning
- type DN
- type Entry
- func (e *Entry) GetAttributeValue(attribute string) string
- func (e *Entry) GetAttributeValues(attribute string) []string
- func (e *Entry) GetRawAttributeValue(attribute string) []byte
- func (e *Entry) GetRawAttributeValues(attribute string) [][]byte
- func (e *Entry) PrettyPrint(indent int)
- func (e *Entry) Print()
- type EntryAttribute
- type Error
- type ModifyRequest
- type PartialAttribute
- type PasswordModifyRequest
- type PasswordModifyResult
- type RelativeDN
- type SearchRequest
- type SearchResult
- type SimpleBindRequest
- type SimpleBindResult
Constants ¶
const ( MessageQuit = 0 MessageRequest = 1 MessageResponse = 2 MessageFinish = 3 )
const ( ControlTypePaging = "1.2.840.113556.1.4.319" ControlTypeBeheraPasswordPolicy = "1.3.6.1.4.1.42.2.27.8.5.1" ControlTypeVChuPasswordMustChange = "2.16.840.1.113730.3.4.4" ControlTypeVChuPasswordWarning = "2.16.840.1.113730.3.4.5" )
const ( FilterAnd = 0 FilterOr = 1 FilterNot = 2 FilterEqualityMatch = 3 FilterSubstrings = 4 FilterGreaterOrEqual = 5 FilterLessOrEqual = 6 FilterPresent = 7 FilterApproxMatch = 8 FilterExtensibleMatch = 9 )
const ( FilterSubstringsInitial = 0 FilterSubstringsAny = 1 FilterSubstringsFinal = 2 )
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 ( LDAPResultSuccess = 0 LDAPResultOperationsError = 1 LDAPResultProtocolError = 2 LDAPResultTimeLimitExceeded = 3 LDAPResultSizeLimitExceeded = 4 LDAPResultCompareFalse = 5 LDAPResultCompareTrue = 6 LDAPResultAuthMethodNotSupported = 7 LDAPResultStrongAuthRequired = 8 LDAPResultReferral = 10 LDAPResultAdminLimitExceeded = 11 LDAPResultConfidentialityRequired = 13 LDAPResultSaslBindInProgress = 14 LDAPResultNoSuchAttribute = 16 LDAPResultUndefinedAttributeType = 17 LDAPResultInappropriateMatching = 18 LDAPResultConstraintViolation = 19 LDAPResultAttributeOrValueExists = 20 LDAPResultInvalidAttributeSyntax = 21 LDAPResultNoSuchObject = 32 LDAPResultAliasProblem = 33 LDAPResultInvalidDNSyntax = 34 LDAPResultAliasDereferencingProblem = 36 LDAPResultInappropriateAuthentication = 48 LDAPResultInvalidCredentials = 49 LDAPResultInsufficientAccessRights = 50 LDAPResultBusy = 51 LDAPResultUnwillingToPerform = 53 LDAPResultLoopDetect = 54 LDAPResultNamingViolation = 64 LDAPResultObjectClassViolation = 65 LDAPResultNotAllowedOnNonLeaf = 66 LDAPResultNotAllowedOnRDN = 67 LDAPResultEntryAlreadyExists = 68 LDAPResultObjectClassModsProhibited = 69 LDAPResultAffectsMultipleDSAs = 71 LDAPResultOther = 80 ErrorNetwork = 200 ErrorFilterCompile = 201 ErrorFilterDecompile = 202 ErrorDebugging = 203 ErrorUnexpectedMessage = 204 ErrorUnexpectedResponse = 205 )
LDAP Result Codes
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 )
const ( ScopeBaseObject = 0 ScopeSingleLevel = 1 ScopeWholeSubtree = 2 )
const ( NeverDerefAliases = 0 DerefInSearching = 1 DerefFindingBaseObj = 2 DerefAlways = 3 )
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 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", }
var ControlTypeMap = map[string]string{ ControlTypePaging: "Paging", ControlTypeBeheraPasswordPolicy: "Password Policy - Behera Draft", }
var DefaultTimeout = 60 * time.Second
DefaultTimeout is a package-level variable that sets the timeout value used for the Dial and DialTLS methods.
WARNING: since this is a package-level variable, setting this value from multiple places will probably result in undesired behaviour.
var DerefMap = map[int]string{ NeverDerefAliases: "NeverDerefAliases", DerefInSearching: "DerefInSearching", DerefFindingBaseObj: "DerefFindingBaseObj", DerefAlways: "DerefAlways", }
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", }
var FilterSubstringsMap = map[uint64]string{ FilterSubstringsInitial: "Substrings Initial", FilterSubstringsAny: "Substrings Any", FilterSubstringsFinal: "Substrings Final", }
var LDAPResultCodeMap = map[uint8]string{ LDAPResultSuccess: "Success", LDAPResultOperationsError: "Operations Error", LDAPResultProtocolError: "Protocol Error", LDAPResultTimeLimitExceeded: "Time Limit Exceeded", LDAPResultSizeLimitExceeded: "Size Limit Exceeded", LDAPResultCompareFalse: "Compare False", LDAPResultCompareTrue: "Compare True", LDAPResultAuthMethodNotSupported: "Auth Method Not Supported", LDAPResultStrongAuthRequired: "Strong Auth Required", LDAPResultReferral: "Referral", LDAPResultAdminLimitExceeded: "Admin Limit Exceeded", LDAPResultUnavailableCriticalExtension: "Unavailable Critical Extension", LDAPResultConfidentialityRequired: "Confidentiality Required", LDAPResultSaslBindInProgress: "Sasl Bind In Progress", LDAPResultNoSuchAttribute: "No Such Attribute", LDAPResultUndefinedAttributeType: "Undefined Attribute Type", LDAPResultInappropriateMatching: "Inappropriate Matching", LDAPResultConstraintViolation: "Constraint Violation", LDAPResultAttributeOrValueExists: "Attribute Or Value Exists", LDAPResultInvalidAttributeSyntax: "Invalid Attribute Syntax", LDAPResultNoSuchObject: "No Such Object", LDAPResultAliasProblem: "Alias Problem", LDAPResultInvalidDNSyntax: "Invalid DN Syntax", LDAPResultAliasDereferencingProblem: "Alias Dereferencing Problem", LDAPResultInappropriateAuthentication: "Inappropriate Authentication", LDAPResultInvalidCredentials: "Invalid Credentials", LDAPResultInsufficientAccessRights: "Insufficient Access Rights", LDAPResultBusy: "Busy", LDAPResultUnavailable: "Unavailable", LDAPResultUnwillingToPerform: "Unwilling To Perform", LDAPResultLoopDetect: "Loop Detect", LDAPResultNamingViolation: "Naming Violation", LDAPResultObjectClassViolation: "Object Class Violation", LDAPResultNotAllowedOnNonLeaf: "Not Allowed On Non Leaf", LDAPResultNotAllowedOnRDN: "Not Allowed On RDN", LDAPResultEntryAlreadyExists: "Entry Already Exists", LDAPResultObjectClassModsProhibited: "Object Class Mods Prohibited", LDAPResultAffectsMultipleDSAs: "Affects Multiple DSAs", LDAPResultOther: "Other", }
var ScopeMap = map[int]string{ ScopeBaseObject: "Base Object", ScopeSingleLevel: "Single Level", ScopeWholeSubtree: "Whole Subtree", }
Functions ¶
func CompileFilter ¶
func DebugBinaryFile ¶
func DecompileFilter ¶
func EscapeFilter ¶
EscapeFilter escapes from the provided LDAP filter string the special characters in the set `()*\` and those out of the range 0 < c < 0x80, as defined in RFC4515.
Types ¶
type AttributeTypeAndValue ¶
type Conn ¶
type Conn struct { Debug debugging // contains filtered or unexported fields }
Conn represents an LDAP Connection
func Dial ¶
Dial connects to the given address on the given network using net.Dial and then returns a new Conn for the connection.
func DialTLS ¶
DialTLS connects to the given address on the given network using tls.Dial and then returns a new Conn for the connection.
func (*Conn) Compare ¶
Compare checks to see if the attribute of the dn matches value. Returns true if it does otherwise false with any error that occurs if any.
func (*Conn) Modify ¶
func (l *Conn) Modify(modifyRequest *ModifyRequest) error
func (*Conn) PasswordModify ¶
func (l *Conn) PasswordModify(passwordModifyRequest *PasswordModifyRequest) (*PasswordModifyResult, error)
func (*Conn) Search ¶
func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error)
func (*Conn) SearchWithPaging ¶
func (l *Conn) SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error)
func (*Conn) SimpleBind ¶
func (l *Conn) SimpleBind(simpleBindRequest *SimpleBindRequest) (*SimpleBindResult, error)
type Control ¶
func DecodeControl ¶
func DecodeControl(packet *ber.Packet) Control
func FindControl ¶
type ControlBeheraPasswordPolicy ¶
func NewControlBeheraPasswordPolicy ¶
func NewControlBeheraPasswordPolicy() *ControlBeheraPasswordPolicy
func (*ControlBeheraPasswordPolicy) Encode ¶
func (c *ControlBeheraPasswordPolicy) Encode() *ber.Packet
func (*ControlBeheraPasswordPolicy) GetControlType ¶
func (c *ControlBeheraPasswordPolicy) GetControlType() string
func (*ControlBeheraPasswordPolicy) String ¶
func (c *ControlBeheraPasswordPolicy) String() string
type ControlPaging ¶
func NewControlPaging ¶
func NewControlPaging(pagingSize uint32) *ControlPaging
func (*ControlPaging) Encode ¶
func (c *ControlPaging) Encode() *ber.Packet
func (*ControlPaging) GetControlType ¶
func (c *ControlPaging) GetControlType() string
func (*ControlPaging) SetCookie ¶
func (c *ControlPaging) SetCookie(cookie []byte)
func (*ControlPaging) String ¶
func (c *ControlPaging) String() string
type ControlString ¶
func NewControlString ¶
func NewControlString(controlType string, criticality bool, controlValue string) *ControlString
func (*ControlString) Encode ¶
func (c *ControlString) Encode() *ber.Packet
func (*ControlString) GetControlType ¶
func (c *ControlString) GetControlType() string
func (*ControlString) String ¶
func (c *ControlString) String() string
type ControlVChuPasswordMustChange ¶
type ControlVChuPasswordMustChange struct {
MustChange bool
}
func (*ControlVChuPasswordMustChange) Encode ¶
func (c *ControlVChuPasswordMustChange) Encode() *ber.Packet
func (*ControlVChuPasswordMustChange) GetControlType ¶
func (c *ControlVChuPasswordMustChange) GetControlType() string
func (*ControlVChuPasswordMustChange) String ¶
func (c *ControlVChuPasswordMustChange) String() string
type ControlVChuPasswordWarning ¶
type ControlVChuPasswordWarning struct {
Expire int64
}
func (*ControlVChuPasswordWarning) Encode ¶
func (c *ControlVChuPasswordWarning) Encode() *ber.Packet
func (*ControlVChuPasswordWarning) GetControlType ¶
func (c *ControlVChuPasswordWarning) GetControlType() string
func (*ControlVChuPasswordWarning) String ¶
func (c *ControlVChuPasswordWarning) String() string
type DN ¶
type DN struct {
RDNs []*RelativeDN
}
type Entry ¶
type Entry struct { DN string Attributes []*EntryAttribute }
func (*Entry) GetAttributeValue ¶
func (*Entry) GetAttributeValues ¶
func (*Entry) GetRawAttributeValue ¶
func (*Entry) GetRawAttributeValues ¶
func (*Entry) PrettyPrint ¶
type EntryAttribute ¶
func (*EntryAttribute) PrettyPrint ¶
func (e *EntryAttribute) PrettyPrint(indent int)
func (*EntryAttribute) Print ¶
func (e *EntryAttribute) Print()
type ModifyRequest ¶
type ModifyRequest struct {
// contains filtered or unexported fields
}
func NewModifyRequest ¶
func NewModifyRequest( dn string, ) *ModifyRequest
func (*ModifyRequest) Add ¶
func (m *ModifyRequest) Add(attrType string, attrVals []string)
func (*ModifyRequest) Delete ¶
func (m *ModifyRequest) Delete(attrType string, attrVals []string)
func (*ModifyRequest) Replace ¶
func (m *ModifyRequest) Replace(attrType string, attrVals []string)
type PartialAttribute ¶
type PartialAttribute struct {
// contains filtered or unexported fields
}
type PasswordModifyRequest ¶
func NewPasswordModifyRequest ¶
func NewPasswordModifyRequest(userIdentity string, oldPassword string, newPassword string) *PasswordModifyRequest
Create a new PasswordModifyRequest
According to the RFC 3602: userIdentity is a string representing the user associated with the request. This string may or may not be an LDAPDN (RFC 2253). If userIdentity is empty then the operation will act on the user associated with the session.
oldPassword is the current user's password, it can be empty or it can be needed depending on the session user access rights (usually an administrator can change a user's password without knowing the current one) and the password policy (see pwdSafeModify password policy's attribute)
newPassword is the desired user's password. If empty the server can return an error or generate a new password that will be available in the PasswordModifyResult.GeneratedPassword
type PasswordModifyResult ¶
type PasswordModifyResult struct {
GeneratedPassword string
}
type RelativeDN ¶
type RelativeDN struct {
Attributes []*AttributeTypeAndValue
}
type SearchRequest ¶
type SearchRequest struct { BaseDN string Scope int DerefAliases int SizeLimit int TimeLimit int TypesOnly bool Filter string Attributes []string Controls []Control }
func NewSearchRequest ¶
type SearchResult ¶
func (*SearchResult) PrettyPrint ¶
func (s *SearchResult) PrettyPrint(indent int)
func (*SearchResult) Print ¶
func (s *SearchResult) Print()
type SimpleBindRequest ¶
func NewSimpleBindRequest ¶
func NewSimpleBindRequest(username string, password string, controls []Control) *SimpleBindRequest
type SimpleBindResult ¶
type SimpleBindResult struct {
Controls []Control
}