PcapPlusPlus  Next
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
LdapLayer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Layer.h"
4 #include "Asn1Codec.h"
5 #include <ostream>
6 #include <string>
7 #include <functional>
8 
10 
13 namespace pcpp
14 {
18  {
19  public:
21  enum Value : uint8_t
22  {
66  Unknown = 255
67  };
68 
69  LdapOperationType() = default;
70 
71  // cppcheck-suppress noExplicitConstructor
74  constexpr LdapOperationType(Value value) : m_Value(value)
75  {}
76 
78  std::string toString() const;
79 
84  static LdapOperationType fromUintValue(uint8_t value);
85 
86  // Allow switch and comparisons.
87  constexpr operator Value() const
88  {
89  return m_Value;
90  }
91 
92  // Prevent usage: if(LdapOperationType)
93  explicit operator bool() const = delete;
94 
95  private:
97  };
98 
102  {
103  public:
105  enum Value : uint8_t
106  {
108  Success = 0,
133  Referral = 10,
183  Busy = 51,
214  Other = 80,
216  Unknown = 255
217  };
218 
219  LdapResultCode() = default;
220 
221  // cppcheck-suppress noExplicitConstructor
224  constexpr LdapResultCode(Value value) : m_Value(value)
225  {}
226 
228  std::string toString() const;
229 
234  static LdapResultCode fromUintValue(uint8_t value);
235 
236  // Allow switch and comparisons
237  constexpr operator Value() const
238  {
239  return m_Value;
240  }
241 
242  // Prevent usage: if(LdapResultCode)
243  explicit operator bool() const = delete;
244 
245  private:
246  Value m_Value = LdapResultCode::Unknown;
247  };
248 
251  struct LdapControl
252  {
254  std::string controlType;
256  std::string controlValue;
257 
261  bool operator==(const LdapControl& other) const
262  {
263  return controlType == other.controlType && controlValue == other.controlValue;
264  }
265  };
266 
270  {
272  std::string type;
274  std::vector<std::string> values;
275 
279  bool operator==(const LdapAttribute& other) const
280  {
281  return type == other.type && values == other.values;
282  }
283  };
284 
287  class LdapLayer : public Layer
288  {
289  public:
296  LdapLayer(uint16_t messageId, LdapOperationType operationType, const std::vector<Asn1Record*>& messageRecords,
297  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
298 
299  ~LdapLayer() override = default;
300 
304 
308 
310  uint16_t getMessageID() const;
311 
314  std::vector<LdapControl> getControls() const;
315 
319 
338  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
339  {
340  return internalTryGet(this, method, result);
341  }
342 
346  static bool isLdapPort(uint16_t port)
347  {
348  return port == 389;
349  }
350 
357  static LdapLayer* parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
358 
359  // implement abstract methods
360 
362  void parseNextLayer() override;
363 
365  size_t getHeaderLen() const override
366  {
367  return m_Asn1Record->getTotalLength();
368  }
369 
370  void computeCalculateFields() override
371  {}
372 
374  {
376  }
377 
378  std::string toString() const override;
379 
380  protected:
381  std::unique_ptr<Asn1Record> m_Asn1Record;
382 
383  LdapLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
384  Packet* packet);
385  LdapLayer() = default;
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
389  {
390  return "";
391  }
392 
393  static constexpr int messageIdIndex = 0;
394  static constexpr int operationTypeIndex = 1;
395  static constexpr int controlsIndex = 2;
396 
397  static constexpr int controlTypeIndex = 0;
398  static constexpr int controlValueIndex = 1;
399 
400  template <typename LdapClass, typename Method, typename ResultType>
401  bool internalTryGet(LdapClass* thisPtr, Method method, ResultType& result)
402  {
403  try
404  {
405  result = std::mem_fn(method)(thisPtr);
406  return true;
407  }
408  catch (...)
409  {
410  return false;
411  }
412  }
413  };
414 
419  {
420  public:
423 
426  std::string getMatchedDN() const;
427 
430  std::string getDiagnosticMessage() const;
431 
434  std::vector<std::string> getReferral() const;
435 
436  protected:
437  static constexpr int resultCodeIndex = 0;
438  static constexpr int matchedDNIndex = 1;
439  static constexpr int diagnotsticsMessageIndex = 2;
440  static constexpr int referralIndex = 3;
441 
442  static constexpr uint8_t referralTagType = 3;
443 
444  LdapResponseLayer() = default;
445  LdapResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
446  Packet* packet)
447  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
448  {}
449 
450  LdapResponseLayer(uint16_t messageId, LdapOperationType operationType, LdapResultCode resultCode,
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>());
454 
455  void init(uint16_t messageId, LdapOperationType operationType, LdapResultCode resultCode,
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>());
460 
461  std::string getExtendedInfoString() const override;
462  };
463 
467  {
468  public:
470  enum class AuthenticationType : uint8_t
471  {
473  Simple = 0,
475  Sasl = 3,
477  NotApplicable = 255
478  };
479 
483  {
485  std::string mechanism;
487  std::vector<uint8_t> credentials;
488 
492  bool operator==(const SaslAuthentication& other) const
493  {
494  return mechanism == other.mechanism && credentials == other.credentials;
495  }
496 
500  bool operator!=(const SaslAuthentication& other) const
501  {
502  return !operator==(other);
503  }
504  };
505 
513  LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string& name,
514  const std::string& simpleAuthentication,
515  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
516 
524  LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string& name,
525  const SaslAuthentication& saslAuthentication,
526  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
527 
529  uint32_t getVersion() const;
530 
532  std::string getName() const;
533 
536 
539  std::string getSimpleAuthentication() const;
540 
544 
545  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
546  {
547  return internalTryGet(this, method, result);
548  }
549 
550  protected:
551  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
552 
553  LdapBindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
554  Packet* packet)
555  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
556  {}
557 
558  std::string getExtendedInfoString() const override;
559 
560  private:
561  static constexpr int versionIndex = 0;
562  static constexpr int nameIndex = 1;
563  static constexpr int credentialIndex = 2;
564 
565  static constexpr int saslMechanismIndex = 0;
566  static constexpr int saslCredentialsIndex = 1;
567  };
568 
572  {
573  public:
586  LdapBindResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>());
591 
593  std::vector<uint8_t> getServerSaslCredentials() const;
594 
595  protected:
596  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
597 
598  static constexpr int serverSaslCredentialsTagType = 7;
599 
600  LdapBindResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
601  Packet* packet)
602  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
603  {}
604  };
605 
609  {
610  public:
615  explicit LdapUnbindRequestLayer(uint16_t messageId,
616  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
617 
618  // Unbind request has no operation record
619  Asn1ConstructedRecord* getLdapOperationAsn1Record() const = delete;
620 
622  {
624  }
625 
626  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
627  {
628  return internalTryGet(this, method, result);
629  }
630 
631  protected:
632  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
633 
634  LdapUnbindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
635  Packet* packet)
636  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
637  {}
638  };
639 
643  {
644  public:
648  {
649  public:
651  enum Value : uint8_t
652  {
666  Unknown = 255
667  };
668 
669  SearchRequestScope() = default;
670 
671  // cppcheck-suppress noExplicitConstructor
674  constexpr SearchRequestScope(Value value) : m_Value(value)
675  {}
676 
678  std::string toString() const;
679 
684  static SearchRequestScope fromUintValue(uint8_t value);
685 
686  // Allow switch and comparisons.
687  constexpr operator Value() const
688  {
689  return m_Value;
690  }
691 
692  // Prevent usage: if(LdapOperationType)
693  explicit operator bool() const = delete;
694 
695  private:
697  };
698 
702  {
703  public:
705  enum Value : uint8_t
706  {
716  Unknown = 255
717  };
718 
719  DerefAliases() = default;
720 
721  // cppcheck-suppress noExplicitConstructor
724  constexpr DerefAliases(Value value) : m_Value(value)
725  {}
726 
728  std::string toString() const;
729 
734  static DerefAliases fromUintValue(uint8_t value);
735 
736  // Allow switch and comparisons.
737  constexpr operator Value() const
738  {
739  return m_Value;
740  }
741 
742  // Prevent usage: if(LdapOperationType)
743  explicit operator bool() const = delete;
744 
745  private:
746  Value m_Value = DerefAliases::Unknown;
747  };
748 
768  LdapSearchRequestLayer(uint16_t messageId, const std::string& baseObject, SearchRequestScope scope,
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>());
772 
774  std::string getBaseObject() const;
775 
778 
781 
783  uint8_t getSizeLimit() const;
784 
786  uint8_t getTimeLimit() const;
787 
792  bool getTypesOnly() const;
793 
797 
799  std::vector<std::string> getAttributes() const;
800 
801  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
802  {
803  return internalTryGet(this, method, result);
804  }
805 
806  protected:
807  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
808 
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;
817 
818  LdapSearchRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
819  Packet* packet)
820  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
821  {}
822 
823  std::string getExtendedInfoString() const override;
824  };
825 
829  {
830  public:
837  LdapSearchResultEntryLayer(uint16_t messageId, const std::string& objectName,
838  const std::vector<LdapAttribute>& attributes,
839  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
840 
842  std::string getObjectName() const;
843 
845  std::vector<LdapAttribute> getAttributes() const;
846 
847  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
848  {
849  return internalTryGet(this, method, result);
850  }
851 
852  protected:
853  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
854 
855  static constexpr int objectNameIndex = 0;
856  static constexpr int attributesIndex = 1;
857  static constexpr int attributeTypeIndex = 0;
858  static constexpr int attributeValueIndex = 1;
859 
860  LdapSearchResultEntryLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
861  Layer* prevLayer, Packet* packet)
862  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
863  {}
864  };
865 
869  {
870  public:
882  LdapSearchResultDoneLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>())
886  : LdapResponseLayer(messageId, LdapOperationType::SearchResultDone, resultCode, matchedDN,
887  diagnosticMessage, referral, controls)
888  {}
889 
890  protected:
891  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
892 
893  LdapSearchResultDoneLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
894  Layer* prevLayer, Packet* packet)
895  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
896  {}
897  };
898 
902  {
903  public:
915  LdapModifyResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>())
919  : LdapResponseLayer(messageId, LdapOperationType::ModifyResponse, resultCode, matchedDN, diagnosticMessage,
920  referral, controls)
921  {}
922 
923  protected:
924  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
925 
926  LdapModifyResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
927  Packet* packet)
928  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
929  {}
930  };
931 
935  {
936  public:
948  LdapAddResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>())
952  : LdapResponseLayer(messageId, LdapOperationType::AddResponse, resultCode, matchedDN, diagnosticMessage,
953  referral, controls)
954  {}
955 
956  protected:
957  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
958 
959  LdapAddResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
960  Packet* packet)
961  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
962  {}
963  };
964 
968  {
969  public:
981  LdapDeleteResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>())
985  : LdapResponseLayer(messageId, LdapOperationType::DeleteResponse, resultCode, matchedDN, diagnosticMessage,
986  referral, controls)
987  {}
988 
989  protected:
990  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
991 
992  LdapDeleteResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
993  Packet* packet)
994  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
995  {}
996  };
997 
1001  {
1002  public:
1014  LdapModifyDNResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>())
1018  : LdapResponseLayer(messageId, LdapOperationType::ModifyDNResponse, resultCode, matchedDN,
1019  diagnosticMessage, referral, controls)
1020  {}
1021 
1022  protected:
1023  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1024 
1025  LdapModifyDNResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1026  Layer* prevLayer, Packet* packet)
1027  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1028  {}
1029  };
1030 
1034  {
1035  public:
1047  LdapCompareResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
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>())
1051  : LdapResponseLayer(messageId, LdapOperationType::CompareResponse, resultCode, matchedDN, diagnosticMessage,
1052  referral, controls)
1053  {}
1054 
1055  protected:
1056  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1057 
1058  LdapCompareResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1059  Layer* prevLayer, Packet* packet)
1060  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1061  {}
1062  };
1063 
1064  inline std::ostream& operator<<(std::ostream& os, const pcpp::LdapControl& control)
1065  {
1066  os << "{" << control.controlType << ", " << control.controlValue << "}";
1067  return os;
1068  }
1069 
1070  inline std::ostream& operator<<(std::ostream& os, const pcpp::LdapAttribute& attr)
1071  {
1072  os << "{" << attr.type << ", {";
1073 
1074  std::string separator;
1075  for (const auto& value : attr.values)
1076  {
1077  os << separator << value;
1078  if (separator.empty())
1079  {
1080  separator = ", ";
1081  }
1082  }
1083 
1084  os << "}}";
1085  return os;
1086  }
1087 
1088  inline std::ostream& operator<<(std::ostream& os,
1089  const pcpp::LdapBindRequestLayer::SaslAuthentication& saslAuthentication)
1090  {
1091  os << "{" << saslAuthentication.mechanism << ", {";
1092 
1093  std::string separator;
1094  for (const auto& value : saslAuthentication.credentials)
1095  {
1096  os << separator << "0x" << std::hex << static_cast<int>(value) << std::dec;
1097  if (separator.empty())
1098  {
1099  separator = ", ";
1100  }
1101  }
1102 
1103  os << "}}";
1104  return os;
1105  }
1106 } // namespace pcpp
Definition: Asn1Codec.h:259
Definition: Asn1Codec.h:114
Definition: Asn1Codec.h:319
Definition: Layer.h:60
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
@ 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)
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
constexpr DerefAliases(Value value)
Definition: LdapLayer.h:724
Value
Define enum types and the corresponding int values.
Definition: LdapLayer.h:652
@ subordinateSubtree
Definition: LdapLayer.h:664
@ BaseObject
The search operation should only be performed against the entry specified as the search base DN.
Definition: LdapLayer.h:654
@ Unknown
Unknown or unsupported scope.
Definition: LdapLayer.h:666
constexpr SearchRequestScope(Value value)
Definition: LdapLayer.h:674
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
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 >())
Definition: Packet.h:22
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
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