87 constexpr
operator Value()
const
93 explicit operator bool()
const =
delete;
237 constexpr
operator Value()
const
243 explicit operator bool()
const =
delete;
297 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
338 template <
typename Method,
typename ResultType>
bool tryGet(Method method, ResultType& result)
340 return internalTryGet(
this, method, result);
367 return m_Asn1Record->getTotalLength();
381 std::unique_ptr<Asn1Record> m_Asn1Record;
383 LdapLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data,
size_t dataLen,
Layer* prevLayer,
386 void init(uint16_t messageId,
LdapOperationType operationType,
const std::vector<Asn1Record*>& messageRecords,
387 const std::vector<LdapControl>& controls);
388 virtual std::string getExtendedInfoString()
const
393 static constexpr
int messageIdIndex = 0;
394 static constexpr
int operationTypeIndex = 1;
395 static constexpr
int controlsIndex = 2;
397 static constexpr
int controlTypeIndex = 0;
398 static constexpr
int controlValueIndex = 1;
400 template <
typename LdapClass,
typename Method,
typename ResultType>
401 bool internalTryGet(LdapClass* thisPtr, Method method, ResultType& result)
405 result = std::mem_fn(method)(thisPtr);
437 static constexpr
int resultCodeIndex = 0;
438 static constexpr
int matchedDNIndex = 1;
439 static constexpr
int diagnotsticsMessageIndex = 2;
440 static constexpr
int referralIndex = 3;
442 static constexpr uint8_t referralTagType = 3;
445 LdapResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data,
size_t dataLen,
Layer* prevLayer,
447 :
LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
451 const std::string& matchedDN,
const std::string& diagnosticMessage,
452 const std::vector<std::string>& referral = std::vector<std::string>(),
453 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
456 const std::string& matchedDN,
const std::string& diagnosticMessage,
457 const std::vector<std::string>& referral = std::vector<std::string>(),
458 const std::vector<Asn1Record*>& additionalRecords = std::vector<Asn1Record*>(),
459 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
461 std::string getExtendedInfoString()
const override;
514 const std::string& simpleAuthentication,
515 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
526 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
545 template <
typename Method,
typename ResultType>
bool tryGet(Method method, ResultType& result)
547 return internalTryGet(
this, method, result);
555 :
LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
558 std::string getExtendedInfoString()
const override;
561 static constexpr
int versionIndex = 0;
562 static constexpr
int nameIndex = 1;
563 static constexpr
int credentialIndex = 2;
565 static constexpr
int saslMechanismIndex = 0;
566 static constexpr
int saslCredentialsIndex = 1;
587 const std::string& diagnosticMessage,
588 const std::vector<std::string>& referral = std::vector<std::string>(),
589 const std::vector<uint8_t>& serverSaslCredentials = std::vector<uint8_t>(),
590 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
598 static constexpr
int serverSaslCredentialsTagType = 7;
616 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
626 template <
typename Method,
typename ResultType>
bool tryGet(Method method, ResultType& result)
628 return internalTryGet(
this, method, result);
634 LdapUnbindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data,
size_t dataLen, Layer* prevLayer,
636 : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
687 constexpr
operator Value()
const
693 explicit operator bool()
const =
delete;
737 constexpr
operator Value()
const
743 explicit operator bool()
const =
delete;
769 DerefAliases derefAliases, uint8_t sizeLimit, uint8_t timeLimit,
bool typesOnly,
770 Asn1Record* filterRecord,
const std::vector<std::string>& attributes,
771 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
801 template <
typename Method,
typename ResultType>
bool tryGet(Method method, ResultType& result)
803 return internalTryGet(
this, method, result);
809 static constexpr
int baseObjectIndex = 0;
810 static constexpr
int scopeIndex = 1;
811 static constexpr
int derefAliasIndex = 2;
812 static constexpr
int sizeLimitIndex = 3;
813 static constexpr
int timeLimitIndex = 4;
814 static constexpr
int typesOnlyIndex = 5;
815 static constexpr
int filterIndex = 6;
816 static constexpr
int attributesIndex = 7;
820 :
LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
823 std::string getExtendedInfoString()
const override;
838 const std::vector<LdapAttribute>& attributes,
839 const std::vector<LdapControl>& controls = std::vector<LdapControl>());
847 template <
typename Method,
typename ResultType>
bool tryGet(Method method, ResultType& result)
849 return internalTryGet(
this, method, result);
855 static constexpr
int objectNameIndex = 0;
856 static constexpr
int attributesIndex = 1;
857 static constexpr
int attributeTypeIndex = 0;
858 static constexpr
int attributeValueIndex = 1;
862 :
LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
883 const std::string& diagnosticMessage,
884 const std::vector<std::string>& referral = std::vector<std::string>(),
885 const std::vector<LdapControl>& controls = std::vector<LdapControl>())
887 diagnosticMessage, referral, controls)
916 const std::string& diagnosticMessage,
917 const std::vector<std::string>& referral = std::vector<std::string>(),
918 const std::vector<LdapControl>& controls = std::vector<LdapControl>())
949 const std::string& diagnosticMessage,
950 const std::vector<std::string>& referral = std::vector<std::string>(),
951 const std::vector<LdapControl>& controls = std::vector<LdapControl>())
982 const std::string& diagnosticMessage,
983 const std::vector<std::string>& referral = std::vector<std::string>(),
984 const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1015 const std::string& diagnosticMessage,
1016 const std::vector<std::string>& referral = std::vector<std::string>(),
1017 const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1019 diagnosticMessage, referral, controls)
1048 const std::string& diagnosticMessage,
1049 const std::vector<std::string>& referral = std::vector<std::string>(),
1050 const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1064 inline std::ostream& operator<<(std::ostream& os,
const pcpp::LdapControl& control)
1072 os <<
"{" << attr.
type <<
", {";
1074 std::string separator;
1075 for (
const auto& value : attr.
values)
1077 os << separator << value;
1078 if (separator.empty())
1088 inline std::ostream& operator<<(std::ostream& os,
1091 os <<
"{" << saslAuthentication.
mechanism <<
", {";
1093 std::string separator;
1094 for (
const auto& value : saslAuthentication.
credentials)
1096 os << separator <<
"0x" << std::hex << static_cast<int>(value) << std::dec;
1097 if (separator.empty())
Definition: Asn1Codec.h:259
Definition: Asn1Codec.h:114
Definition: Asn1Codec.h:319
Definition: LdapLayer.h:935
LdapAddResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:948
Definition: LdapLayer.h:467
AuthenticationType getAuthenticationType() const
std::string getSimpleAuthentication() const
uint32_t getVersion() const
LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string &name, const SaslAuthentication &saslAuthentication, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
SaslAuthentication getSaslAuthentication() const
AuthenticationType
An enum to represent the bind request authentication type.
Definition: LdapLayer.h:471
@ Simple
Simple authentication.
@ Sasl
SASL authentication.
@ NotApplicable
Unknown / not application authentication type.
std::string getName() const
LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string &name, const std::string &simpleAuthentication, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:572
std::vector< uint8_t > getServerSaslCredentials() const
LdapBindResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< uint8_t > &serverSaslCredentials=std::vector< uint8_t >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:1034
LdapCompareResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:1047
Definition: LdapLayer.h:968
LdapDeleteResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:981
Definition: LdapLayer.h:288
std::string toString() const override
void parseNextLayer() override
Tries to identify more LDAP messages in this packet if exist.
bool tryGet(Method method, ResultType &result)
Definition: LdapLayer.h:338
virtual LdapOperationType getLdapOperationType() const
std::vector< LdapControl > getControls() const
void computeCalculateFields() override
Each layer can compute field values automatically using this method. This is an abstract method.
Definition: LdapLayer.h:370
Asn1ConstructedRecord * getLdapOperationAsn1Record() const
static LdapLayer * parseLdapMessage(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Asn1SequenceRecord * getRootAsn1Record() const
uint16_t getMessageID() const
OsiModelLayer getOsiModelLayer() const override
Definition: LdapLayer.h:373
size_t getHeaderLen() const override
Definition: LdapLayer.h:365
static bool isLdapPort(uint16_t port)
Definition: LdapLayer.h:346
LdapLayer(uint16_t messageId, LdapOperationType operationType, const std::vector< Asn1Record * > &messageRecords, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:1001
LdapModifyDNResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:1014
Definition: LdapLayer.h:902
LdapModifyResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:915
An enum wrapper class for LDAP operation types.
Definition: LdapLayer.h:18
constexpr LdapOperationType(Value value)
Definition: LdapLayer.h:74
Value
Define enum types and the corresponding int values.
Definition: LdapLayer.h:22
@ ModifyResponse
Modify Response.
Definition: LdapLayer.h:38
@ AddResponse
Add Response.
Definition: LdapLayer.h:42
@ BindRequest
Bind Request.
Definition: LdapLayer.h:24
@ SearchResultReference
Search Result Reference.
Definition: LdapLayer.h:58
@ SearchResultEntry
Search Result Entry.
Definition: LdapLayer.h:32
@ ExtendedRequest
Extended Request.
Definition: LdapLayer.h:60
@ ModifyDNRequest
Modify DN (Distinguished Name) Request.
Definition: LdapLayer.h:48
@ DeleteResponse
Delete Response.
Definition: LdapLayer.h:46
@ CompareRequest
Compare Request.
Definition: LdapLayer.h:52
@ BindResponse
Bind Response.
Definition: LdapLayer.h:26
@ SearchRequest
Search Request.
Definition: LdapLayer.h:30
@ ModifyDNResponse
Modify DN (Distinguished Name) Response.
Definition: LdapLayer.h:50
@ ExtendedResponse
Extended Response.
Definition: LdapLayer.h:62
@ IntermediateResponse
Intermediate Response.
Definition: LdapLayer.h:64
@ ModifyRequest
Modify Request.
Definition: LdapLayer.h:36
@ CompareResponse
Compare Response.
Definition: LdapLayer.h:54
@ AddRequest
Add Request.
Definition: LdapLayer.h:40
@ AbandonRequest
Abandon Request.
Definition: LdapLayer.h:56
@ Unknown
Unknown operation type.
Definition: LdapLayer.h:66
@ DeleteRequest
Delete Request.
Definition: LdapLayer.h:44
@ SearchResultDone
Search Result Done.
Definition: LdapLayer.h:34
@ UnbindRequest
Unbind Request.
Definition: LdapLayer.h:28
std::string toString() const
static LdapOperationType fromUintValue(uint8_t value)
Definition: LdapLayer.h:419
std::string getDiagnosticMessage() const
LdapResultCode getResultCode() const
std::string getMatchedDN() const
std::vector< std::string > getReferral() const
An enum wrapper class for LDAP result codes.
Definition: LdapLayer.h:102
Value
Define enum types and the corresponding int values.
Definition: LdapLayer.h:106
@ InsufficientAccessRights
Definition: LdapLayer.h:181
@ InvalidAttributeSyntax
Definition: LdapLayer.h:163
@ AuthMethodNotSupported
Definition: LdapLayer.h:128
@ NotAllowedOnRDN
Definition: LdapLayer.h:203
@ EntryAlreadyExists
Definition: LdapLayer.h:206
@ StrongerAuthRequired
Indicates that the server requires the client to authenticate with a stronger form of authentication.
Definition: LdapLayer.h:130
@ InvalidDNSyntax
Indicates that the request included a malformed entry DN.
Definition: LdapLayer.h:169
@ InappropriateAuthentication
Definition: LdapLayer.h:175
@ ObjectClassViolation
Definition: LdapLayer.h:197
@ ConfidentialityRequired
Definition: LdapLayer.h:142
@ AliasProblem
Indicates that a problem occurred while attempting to dereference an alias during search processing.
Definition: LdapLayer.h:167
@ Busy
Indicates that the requested operation cannot be processed because the server is currently too busy.
Definition: LdapLayer.h:183
@ ProtocolError
Indicates that there was a problem with the client’s use of the LDAP protocol.
Definition: LdapLayer.h:112
@ Unavailable
Indicates that the server is currently not available to process the requested operation.
Definition: LdapLayer.h:185
@ SaslBindInProgress
Definition: LdapLayer.h:145
@ InappropriateMatching
Definition: LdapLayer.h:153
@ CompareFalse
Definition: LdapLayer.h:122
@ AttributeOrValueExists
Definition: LdapLayer.h:159
@ AliasDereferencingProblem
Definition: LdapLayer.h:172
@ AdminLimitExceeded
Indicates that some administrative limit within the server was exceeded while processing the request.
Definition: LdapLayer.h:135
@ Referral
Definition: LdapLayer.h:133
@ SizeLimitExceeded
Definition: LdapLayer.h:119
@ UnwillingToPerform
Indicates that the server is not willing to process the requested operation for some reason.
Definition: LdapLayer.h:187
@ ConstraintViolation
Definition: LdapLayer.h:156
@ NamingViolation
Definition: LdapLayer.h:193
@ UnavailableCriticalExtension
Definition: LdapLayer.h:138
@ ObjectClassModsProhibited
Definition: LdapLayer.h:209
@ Unknown
Unknown result code.
Definition: LdapLayer.h:216
@ Other
Used when a problem occurs for which none of the other result codes is more appropriate.
Definition: LdapLayer.h:214
@ NoSuchAttribute
Indicates that the request targeted an attribute that does not exist in the specified entry.
Definition: LdapLayer.h:147
@ CompareTrue
Definition: LdapLayer.h:125
@ UndefinedAttributeType
Definition: LdapLayer.h:150
@ NoSuchObject
Indicates that the requested operation targeted an entry that does not exist within the DIT.
Definition: LdapLayer.h:165
@ LoopDetect
Definition: LdapLayer.h:190
@ NotAllowedOnNonLeaf
Definition: LdapLayer.h:200
@ TimeLimitExceeded
Definition: LdapLayer.h:115
@ AffectsMultipleDSAs
Definition: LdapLayer.h:212
@ InvalidCredentials
Definition: LdapLayer.h:178
@ OperationsError
Indicates that there was a problem with the client’s use of the LDAP protocol.
Definition: LdapLayer.h:110
@ Success
Indicates that the associated operation completed successfully.
Definition: LdapLayer.h:108
std::string toString() const
constexpr LdapResultCode(Value value)
Definition: LdapLayer.h:224
static LdapResultCode fromUintValue(uint8_t value)
Definition: LdapLayer.h:702
static DerefAliases fromUintValue(uint8_t value)
Value
Define enum types and the corresponding int values.
Definition: LdapLayer.h:706
@ DerefInSearching
Dereferences aliases only after name resolution.
Definition: LdapLayer.h:710
@ DerefFindingBaseObj
Dereferences aliases only during name resolution.
Definition: LdapLayer.h:712
@ Unknown
Unknown value.
Definition: LdapLayer.h:716
@ DerefAlways
Always dereference aliases.
Definition: LdapLayer.h:714
@ NeverDerefAliases
Never dereferences aliases.
Definition: LdapLayer.h:708
std::string toString() const
constexpr DerefAliases(Value value)
Definition: LdapLayer.h:724
Definition: LdapLayer.h:648
Value
Define enum types and the corresponding int values.
Definition: LdapLayer.h:652
@ subordinateSubtree
Definition: LdapLayer.h:664
@ WholeSubtree
Definition: LdapLayer.h:660
@ BaseObject
The search operation should only be performed against the entry specified as the search base DN.
Definition: LdapLayer.h:654
@ SingleLevel
Definition: LdapLayer.h:657
@ Unknown
Unknown or unsupported scope.
Definition: LdapLayer.h:666
constexpr SearchRequestScope(Value value)
Definition: LdapLayer.h:674
std::string toString() const
static SearchRequestScope fromUintValue(uint8_t value)
Definition: LdapLayer.h:643
std::string getBaseObject() const
SearchRequestScope getScope() const
LdapSearchRequestLayer(uint16_t messageId, const std::string &baseObject, SearchRequestScope scope, DerefAliases derefAliases, uint8_t sizeLimit, uint8_t timeLimit, bool typesOnly, Asn1Record *filterRecord, const std::vector< std::string > &attributes, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
DerefAliases getDerefAlias() const
uint8_t getSizeLimit() const
uint8_t getTimeLimit() const
Asn1Record * getFilter() const
std::vector< std::string > getAttributes() const
bool getTypesOnly() const
Definition: LdapLayer.h:869
LdapSearchResultDoneLayer(uint16_t messageId, LdapResultCode resultCode, const std::string &matchedDN, const std::string &diagnosticMessage, const std::vector< std::string > &referral=std::vector< std::string >(), const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:882
Definition: LdapLayer.h:829
std::string getObjectName() const
std::vector< LdapAttribute > getAttributes() const
LdapSearchResultEntryLayer(uint16_t messageId, const std::string &objectName, const std::vector< LdapAttribute > &attributes, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:609
LdapOperationType getLdapOperationType() const override
Definition: LdapLayer.h:621
LdapUnbindRequestLayer(uint16_t messageId, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelApplicationLayer
Application layer (layer 7)
Definition: ProtocolType.h:239
Definition: LdapLayer.h:270
std::string type
Attribute description.
Definition: LdapLayer.h:272
bool operator==(const LdapAttribute &other) const
Definition: LdapLayer.h:279
std::vector< std::string > values
A list of attribute values (zero or more)
Definition: LdapLayer.h:274
Definition: LdapLayer.h:483
std::vector< uint8_t > credentials
Encoded SASL credentials.
Definition: LdapLayer.h:487
std::string mechanism
The SASL mechanism.
Definition: LdapLayer.h:485
bool operator!=(const SaslAuthentication &other) const
Definition: LdapLayer.h:500
bool operator==(const SaslAuthentication &other) const
Definition: LdapLayer.h:492
Definition: LdapLayer.h:252
std::string controlType
LDAP control type.
Definition: LdapLayer.h:254
bool operator==(const LdapControl &other) const
Definition: LdapLayer.h:261
std::string controlValue
LDAP control value.
Definition: LdapLayer.h:256