Documentation
¶
Index ¶
- Constants
- Variables
- func FilterToPacket(f Filter) *ber.Packet
- func FilterToQuery(filter Filter) (string, error)
- func FilterToString(filter Filter, level int) string
- func GetAttrName(filter Filter) (string, error)
- func GetLDAPError(packet *ber.Packet) error
- func IsOID(s string) bool
- func NewError(resultCode uint16, err error) error
- type ADSType
- type AttrEntries
- type Attribute
- type Error
- type Filter
- type FilterAnd
- type FilterApproxMatch
- type FilterEqualityMatch
- type FilterExtensibleMatch
- type FilterGreaterOrEqual
- type FilterLessOrEqual
- type FilterNot
- type FilterOr
- type FilterPresent
- type FilterSubstring
- type FilterType
- type LDAPAttrContext
- type LDAPTitle
- type LDAPTokenFormat
- type MAPIType
- type SDSType
- type SubstringFilter
Constants ¶
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 ApplicationIntermediateResponse = 25 )
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" // ControlTypeSubtreeDelete - https://datatracker.ietf.org/doc/html/draft-armijo-ldap-treedelete-02 ControlTypeSubtreeDelete = "1.2.840.113556.1.4.805" // ControlTypeServerSideSorting - https://www.ietf.org/rfc/rfc2891.txt ControlTypeServerSideSorting = "1.2.840.113556.1.4.473" // ControlTypeServerSideSorting - https://www.ietf.org/rfc/rfc2891.txt ControlTypeServerSideSortingResult = "1.2.840.113556.1.4.474" // 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" // ControlTypeDirSync - Active Directory DirSync - https://msdn.microsoft.com/en-us/library/aa366978(v=vs.85).aspx ControlTypeDirSync = "1.2.840.113556.1.4.841" // ControlTypeSyncRequest - https://www.ietf.org/rfc/rfc4533.txt ControlTypeSyncRequest = "1.3.6.1.4.1.4203.1.9.1.1" // ControlTypeSyncState - https://www.ietf.org/rfc/rfc4533.txt ControlTypeSyncState = "1.3.6.1.4.1.4203.1.9.1.2" // ControlTypeSyncDone - https://www.ietf.org/rfc/rfc4533.txt ControlTypeSyncDone = "1.3.6.1.4.1.4203.1.9.1.3" // ControlTypeSyncInfo - https://www.ietf.org/rfc/rfc4533.txt ControlTypeSyncInfo = "1.3.6.1.4.1.4203.1.9.1.4" )
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 LDAPResultIsLeaf = 35 LDAPResultAliasDereferencingProblem = 36 LDAPResultInappropriateAuthentication = 48 LDAPResultInvalidCredentials = 49 LDAPResultInsufficientAccessRights = 50 LDAPResultBusy = 51 LDAPResultUnwillingToPerform = 53 LDAPResultLoopDetect = 54 LDAPResultSortControlMissing = 60 LDAPResultOffsetRangeError = 61 LDAPResultNamingViolation = 64 LDAPResultObjectClassViolation = 65 LDAPResultNotAllowedOnNonLeaf = 66 LDAPResultNotAllowedOnRDN = 67 LDAPResultEntryAlreadyExists = 68 LDAPResultObjectClassModsProhibited = 69 LDAPResultResultsTooLarge = 70 LDAPResultAffectsMultipleDSAs = 71 LDAPResultVirtualListViewErrorOrControlError = 76 LDAPResultOther = 80 LDAPResultServerDown = 81 LDAPResultLocalError = 82 LDAPResultEncodingError = 83 LDAPResultDecodingError = 84 LDAPResultTimeout = 85 LDAPResultAuthUnknown = 86 LDAPResultFilterError = 87 LDAPResultUserCanceled = 88 LDAPResultParamError = 89 LDAPResultNoMemory = 90 LDAPResultConnectError = 91 LDAPResultNotSupported = 92 LDAPResultControlNotFound = 93 LDAPResultNoResultsReturned = 94 LDAPResultMoreResultsToReturn = 95 LDAPResultClientLoop = 96 LDAPResultReferralLimitExceeded = 97 LDAPResultInvalidResponse = 100 LDAPResultAmbiguousResponse = 101 LDAPResultTLSNotSupported = 112 LDAPResultIntermediateResponse = 113 LDAPResultUnknownType = 114 LDAPResultCanceled = 118 LDAPResultNoSuchOperation = 119 LDAPResultTooLate = 120 LDAPResultCannotCancel = 121 LDAPResultAssertionFailed = 122 LDAPResultAuthorizationDenied = 123 LDAPResultSyncRefreshRequired = 4096 ErrorNetwork = 200 ErrorFilterCompile = 201 ErrorFilterDecompile = 202 ErrorDebugging = 203 ErrorUnexpectedMessage = 204 ErrorUnexpectedResponse = 205 ErrorEmptyPassword = 206 )
LDAP Result Codes
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", ApplicationIntermediateResponse: "Intermediate Response", }
ApplicationMap contains human readable descriptions of LDAP Application Codes
var AttrContexts = map[string]LDAPAttrContext{}/* 1420 elements not displayed */
var BitwiseAttrs = []string{
"acsservicetype", "authenticationoptions", "dhcptype", "flags",
"frsflags", "frsreplicasettype", "gpoptions", "groupattributes",
"grouptype", "instancetype", "ipsecdatatype", "linkid",
"localeid", "localizationdisplayid", "localpolicyflags", "mapiid",
"msdfsr-flags", "msdfsr-options", "msdfsr-replicationgrouptype", "msds-azoperationid",
"msds-intid", "msds-nctype", "msds-optionalfeatureflags", "msieee80211-datatype",
"msmqnt4flags", "msmqostype", "msmqservicetype", "msradiusservicetype",
"mstsendpointtype", "mstsremotecontrol", "nameserviceflags", "nextrid",
"options", "packageflags", "packagetype", "policyreplicationflags",
"primarygroupid", "printattributes", "privilegeattributes", "remotesourcetype",
"rid", "ridnextrid", "rpcnsentryflags", "samaccounttype",
"scopeflags", "searchflags", "syncattributes", "systemflags",
"trustattributes", "trusttype", "useraccountcontrol",
}
var ControlTypeMap = map[string]string{ ControlTypePaging: "Paging", ControlTypeBeheraPasswordPolicy: "Password Policy - Behera Draft", ControlTypeManageDsaIT: "Manage DSA IT", ControlTypeSubtreeDelete: "Subtree Delete Control", ControlTypeMicrosoftNotification: "Change Notification - Microsoft", ControlTypeMicrosoftShowDeleted: "Show Deleted Objects - Microsoft", ControlTypeMicrosoftServerLinkTTL: "Return TTL-DNs for link values with associated expiry times - Microsoft", ControlTypeServerSideSorting: "Server Side Sorting Request - LDAP Control Extension for Server Side Sorting of Search Results (RFC2891)", ControlTypeServerSideSortingResult: "Server Side Sorting Results - LDAP Control Extension for Server Side Sorting of Search Results (RFC2891)", ControlTypeDirSync: "DirSync", ControlTypeSyncRequest: "Sync Request", ControlTypeSyncState: "Sync State", ControlTypeSyncDone: "Sync Done", ControlTypeSyncInfo: "Sync Info", }
ControlTypeMap maps controls to text descriptions
var LDAPResultCodeMap = map[uint16]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", LDAPResultIsLeaf: "Is Leaf", 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", LDAPResultSortControlMissing: "Sort Control Missing", LDAPResultOffsetRangeError: "Result Offset Range Error", LDAPResultNamingViolation: "Naming Violation", LDAPResultObjectClassViolation: "Object Class Violation", LDAPResultResultsTooLarge: "Results Too Large", LDAPResultNotAllowedOnNonLeaf: "Not Allowed On Non Leaf", LDAPResultNotAllowedOnRDN: "Not Allowed On RDN", LDAPResultEntryAlreadyExists: "Entry Already Exists", LDAPResultObjectClassModsProhibited: "Object Class Mods Prohibited", LDAPResultAffectsMultipleDSAs: "Affects Multiple DSAs", LDAPResultVirtualListViewErrorOrControlError: "Failed because of a problem related to the virtual list view", LDAPResultOther: "Other", LDAPResultServerDown: "Cannot establish a connection", LDAPResultLocalError: "An error occurred", LDAPResultEncodingError: "LDAP encountered an error while encoding", LDAPResultDecodingError: "LDAP encountered an error while decoding", LDAPResultTimeout: "LDAP timeout while waiting for a response from the server", LDAPResultAuthUnknown: "The auth method requested in a bind request is unknown", LDAPResultFilterError: "An error occurred while encoding the given search filter", LDAPResultUserCanceled: "The user canceled the operation", LDAPResultParamError: "An invalid parameter was specified", LDAPResultNoMemory: "Out of memory error", LDAPResultConnectError: "A connection to the server could not be established", LDAPResultNotSupported: "An attempt has been made to use a feature not supported LDAP", LDAPResultControlNotFound: "The controls required to perform the requested operation were not found", LDAPResultNoResultsReturned: "No results were returned from the server", LDAPResultMoreResultsToReturn: "There are more results in the chain of results", LDAPResultClientLoop: "A loop has been detected. For example when following referrals", LDAPResultReferralLimitExceeded: "The referral hop limit has been exceeded", LDAPResultCanceled: "Operation was canceled", LDAPResultNoSuchOperation: "Server has no knowledge of the operation requested for cancellation", LDAPResultTooLate: "Too late to cancel the outstanding operation", LDAPResultCannotCancel: "The identified operation does not support cancellation or the cancel operation cannot be performed", LDAPResultAssertionFailed: "An assertion control given in the LDAP operation evaluated to false causing the operation to not be performed", LDAPResultSyncRefreshRequired: "Refresh Required", LDAPResultInvalidResponse: "Invalid Response", LDAPResultAmbiguousResponse: "Ambiguous Response", LDAPResultTLSNotSupported: "Tls Not Supported", LDAPResultIntermediateResponse: "Intermediate Response", LDAPResultUnknownType: "Unknown Type", LDAPResultAuthorizationDenied: "Authorization Denied", ErrorNetwork: "Network Error", ErrorFilterCompile: "Filter Compile Error", ErrorFilterDecompile: "Filter Decompile Error", ErrorDebugging: "Debugging Error", ErrorUnexpectedMessage: "Unexpected Message", ErrorUnexpectedResponse: "Unexpected Response", ErrorEmptyPassword: "Empty password not allowed by the client", }
LDAPResultCodeMap contains string descriptions for LDAP error codes
var NumberFormats = []LDAPTokenFormat{ TokenIntEnumeration, TokenIntTimeInterval, TokenBitwise, }
var OidsMap = map[string]string{}/* 1420 elements not displayed */
var RFCOperationalAttrs = []string{
"createtimestamp", "modifytimestamp", "creatorsname", "modifiersname", "subschemasubentry",
"attributetypes", "objectclasses", "matchingrules", "matchingruleuse", "namingcontexts",
"altserver", "supportedextension", "supportedcontrol", "supportedsaslmechanisms", "supportedldapversion",
"ldapsyntaxes", "ditstructurerules", "nameforms", "ditcontentrules",
}
Operational attributes according to Python's ldap3 and RFC4512
var RootDSEOperationalAttrs = []string{
"dsschemaattrcount", "dsschemaclasscount", "dsschemaprefixcount", "netlogon", "pendingpropagations",
"msds-replallinboundneighbors", "msds-replalloutboundneighbors", "msds-replconnectionfailures",
"msds-repllinkfailures", "msds-replpendingops", "msds-replqueuestatistics", "msds-topquotausage",
"supportedconfigurablesettings", "supportedextension", "validfsmos", "dsaversionstring", "msds-portldap",
"msds-portssl", "msds-principalname", "serviceaccountinfo", "spnregistrationresult", "tokengroups",
"usnatrifm", "approximatehighestinternalobjectid", "databaseguid", "schemaindexupdatestate", "dumpldapnotifications",
"msds-processlinksoperations", "msds-segmentcacheinfo", "msds-threadstates", "configurablesettingseffective",
"ldappolicieseffective", "msds-arenainfo", "msds-anchor", "msds-prefixtable", "msds-supportedrootdseattributes",
"msds-supportedrootdsemodifications", "msds-diskusage", "msds-databaseindices", "msds-databaseindiceswithsize",
"msds-priorityboost",
}
Operational attributes in the RootDSE according to MS-ADTS
Functions ¶
func FilterToPacket ¶
func FilterToQuery ¶
Conversions from Filter to Query and vice-versa
func FilterToString ¶
func GetAttrName ¶
func GetLDAPError ¶
GetLDAPError creates an Error out of a BER packet representing a LDAPResult The return is an error object. It can be casted to a Error structure. This function returns nil if resultCode in the LDAPResult sequence is success(0).
Types ¶
type AttrEntries ¶
type AttrEntries []Attribute
func (*AttrEntries) AddValue ¶
func (a *AttrEntries) AddValue(name string, value string)
func (*AttrEntries) AppendAttr ¶
func (a *AttrEntries) AppendAttr(name string, value string)
type Error ¶
type Error struct { // Err is the underlying error Err error // ResultCode is the LDAP error code ResultCode uint16 // MatchedDN is the matchedDN returned if any MatchedDN string // Packet is the returned packet if any Packet *ber.Packet }
Error holds LDAP error information
type Filter ¶
type Filter interface { // Type returns the type of the filter. Type() FilterType }
Filter is an interface for all LDAP filter types.
func PacketToFilter ¶
Converts a BER packet into a Filter structure
func QueryToFilter ¶
type FilterAnd ¶
type FilterAnd struct {
Filters []Filter
}
FilterAnd represents an AND filter.
func (*FilterAnd) Type ¶
func (f *FilterAnd) Type() FilterType
type FilterApproxMatch ¶
FilterApproxMatch represents an approximate match filter.
func (*FilterApproxMatch) Type ¶
func (f *FilterApproxMatch) Type() FilterType
type FilterEqualityMatch ¶
FilterEqualityMatch represents an equality match filter.
func (*FilterEqualityMatch) Type ¶
func (f *FilterEqualityMatch) Type() FilterType
type FilterExtensibleMatch ¶
type FilterExtensibleMatch struct { MatchingRule string AttributeDesc string MatchValue string DNAttributes bool }
FilterExtensibleMatch represents an extensible match filter.
func (*FilterExtensibleMatch) Type ¶
func (f *FilterExtensibleMatch) Type() FilterType
type FilterGreaterOrEqual ¶
FilterGreaterOrEqual represents a greater-or-equal filter.
func (*FilterGreaterOrEqual) Type ¶
func (f *FilterGreaterOrEqual) Type() FilterType
type FilterLessOrEqual ¶
FilterLessOrEqual represents a less-or-equal filter.
func (*FilterLessOrEqual) Type ¶
func (f *FilterLessOrEqual) Type() FilterType
type FilterNot ¶
type FilterNot struct {
Filter Filter
}
FilterNot represents a NOT filter.
func (*FilterNot) Type ¶
func (f *FilterNot) Type() FilterType
type FilterOr ¶
type FilterOr struct {
Filters []Filter
}
FilterOr represents an OR filter.
func (*FilterOr) Type ¶
func (f *FilterOr) Type() FilterType
type FilterPresent ¶
type FilterPresent struct {
AttributeDesc string
}
FilterPresent represents a presence filter.
func (*FilterPresent) Type ¶
func (f *FilterPresent) Type() FilterType
type FilterSubstring ¶
type FilterSubstring struct { AttributeDesc string Substrings []SubstringFilter }
FilterSubstring represents a substring filter.
func (*FilterSubstring) Type ¶
func (f *FilterSubstring) Type() FilterType
type FilterType ¶
type FilterType int
FilterType represents the various LDAP filter types.
const ( And FilterType = iota Or Not EqualityMatch Substring GreaterOrEqual LessOrEqual Present ApproxMatch ExtensibleMatch )
type LDAPAttrContext ¶
type LDAPTitle ¶
type LDAPTitle int
const ( TitleUndefined LDAPTitle = iota TitleBoolean TitleEnumeration TitleInterval TitleObject_Access_Point TitleObject_DN_Binary TitleObject_DS_DN TitleObject_Presentation_Address TitleObject_Replica_Link TitleString_Generalized_Time TitleString_IA5 TitleString_NT_Sec_Desc TitleString_Numeric TitleString_Object_Identifier TitleString_Sid TitleString_Teletex TitleString_Unicode )
type LDAPTokenFormat ¶
type LDAPTokenFormat int
Types for LDAPAttr Context
const ( TokenUndefined LDAPTokenFormat = iota TokenNA TokenString TokenOID TokenBitwise TokenBoolean TokenDateTime TokenIntTimeInterval TokenDNWithBinary TokenDNString TokenSID TokenIntEnumeration TokenHexObjectReplicaLink TokenStringObjectIdentifier TokenStringUnicode TokenStringIA5 TokenStringNTSecurityDescriptor TokenStringTeletex TokenStringNumeric TokenStringObjectAccessPoint TokenStringObjectPresentationAddress )
func GetAttributeTokenFormat ¶
func GetAttributeTokenFormat(attributeName string) (LDAPTokenFormat, error)
Gets the token format for an attribute
type SubstringFilter ¶
SubstringFilter represents a component of a substring filter. Either Initial, Any or Final will be set.