PcapPlusPlus  24.09
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 
15 namespace pcpp
16 {
22  {
23  public:
27  enum Value : uint8_t
28  {
72  Unknown = 255
73  };
74 
75  LdapOperationType() = default;
76 
77  // cppcheck-suppress noExplicitConstructor
82  constexpr LdapOperationType(Value value) : m_Value(value)
83  {}
84 
88  std::string toString() const;
89 
96  static LdapOperationType fromUintValue(uint8_t value);
97 
98  // Allow switch and comparisons.
99  constexpr operator Value() const
100  {
101  return m_Value;
102  }
103 
104  // Prevent usage: if(LdapOperationType)
105  explicit operator bool() const = delete;
106 
107  private:
109  };
110 
116  {
117  public:
121  enum Value : uint8_t
122  {
126  Success = 0,
169  Referral = 10,
255  Busy = 51,
308  Other = 80,
312  Unknown = 255
313  };
314 
315  LdapResultCode() = default;
316 
317  // cppcheck-suppress noExplicitConstructor
322  constexpr LdapResultCode(Value value) : m_Value(value)
323  {}
324 
328  std::string toString() const;
329 
336  static LdapResultCode fromUintValue(uint8_t value);
337 
338  // Allow switch and comparisons
339  constexpr operator Value() const
340  {
341  return m_Value;
342  }
343 
344  // Prevent usage: if(LdapResultCode)
345  explicit operator bool() const = delete;
346 
347  private:
348  Value m_Value = LdapResultCode::Unknown;
349  };
350 
355  struct LdapControl
356  {
358  std::string controlType;
360  std::string controlValue;
361 
367  bool operator==(const LdapControl& other) const
368  {
369  return controlType == other.controlType && controlValue == other.controlValue;
370  }
371  };
372 
378  {
380  std::string type;
382  std::vector<std::string> values;
383 
389  bool operator==(const LdapAttribute& other) const
390  {
391  return type == other.type && values == other.values;
392  }
393  };
394 
399  class LdapLayer : public Layer
400  {
401  public:
410  LdapLayer(uint16_t messageId, LdapOperationType operationType, const std::vector<Asn1Record*>& messageRecords,
411  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
412 
413  ~LdapLayer()
414  {}
415 
421 
427 
431  uint16_t getMessageID() const;
432 
437  std::vector<LdapControl> getControls() const;
438 
444 
465  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
466  {
467  return internalTryGet(this, method, result);
468  }
469 
475  static bool isLdapPort(uint16_t port)
476  {
477  return port == 389;
478  }
479 
488  static LdapLayer* parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
489 
490  // implement abstract methods
491 
495  void parseNextLayer() override;
496 
500  size_t getHeaderLen() const override
501  {
502  return m_Asn1Record->getTotalLength();
503  }
504 
505  void computeCalculateFields() override
506  {}
507 
509  {
511  }
512 
513  std::string toString() const override;
514 
515  protected:
516  std::unique_ptr<Asn1Record> m_Asn1Record;
517 
518  LdapLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
519  Packet* packet);
520  LdapLayer() = default;
521  void init(uint16_t messageId, LdapOperationType operationType, const std::vector<Asn1Record*>& messageRecords,
522  const std::vector<LdapControl>& controls);
523  virtual std::string getExtendedInfoString() const
524  {
525  return "";
526  }
527 
528  static constexpr int messageIdIndex = 0;
529  static constexpr int operationTypeIndex = 1;
530  static constexpr int controlsIndex = 2;
531 
532  static constexpr int controlTypeIndex = 0;
533  static constexpr int controlValueIndex = 1;
534 
535  template <typename LdapClass, typename Method, typename ResultType>
536  bool internalTryGet(LdapClass* thisPtr, Method method, ResultType& result)
537  {
538  try
539  {
540  result = std::mem_fn(method)(thisPtr);
541  return true;
542  }
543  catch (...)
544  {
545  return false;
546  }
547  }
548  };
549 
556  {
557  public:
562 
567  std::string getMatchedDN() const;
568 
573  std::string getDiagnosticMessage() const;
574 
579  std::vector<std::string> getReferral() const;
580 
581  protected:
582  static constexpr int resultCodeIndex = 0;
583  static constexpr int matchedDNIndex = 1;
584  static constexpr int diagnotsticsMessageIndex = 2;
585  static constexpr int referralIndex = 3;
586 
587  static constexpr uint8_t referralTagType = 3;
588 
589  LdapResponseLayer() = default;
590  LdapResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
591  Packet* packet)
592  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
593  {}
594 
595  LdapResponseLayer(uint16_t messageId, LdapOperationType operationType, LdapResultCode resultCode,
596  const std::string& matchedDN, const std::string& diagnosticMessage,
597  const std::vector<std::string>& referral = std::vector<std::string>(),
598  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
599 
600  void init(uint16_t messageId, LdapOperationType operationType, LdapResultCode resultCode,
601  const std::string& matchedDN, const std::string& diagnosticMessage,
602  const std::vector<std::string>& referral = std::vector<std::string>(),
603  const std::vector<Asn1Record*>& additionalRecords = std::vector<Asn1Record*>(),
604  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
605 
606  std::string getExtendedInfoString() const override;
607  };
608 
614  {
615  public:
619  enum class AuthenticationType : uint8_t
620  {
622  Simple = 0,
624  Sasl = 3,
626  NotApplicable = 255
627  };
628 
634  {
636  std::string mechanism;
638  std::vector<uint8_t> credentials;
639 
645  bool operator==(const SaslAuthentication& other) const
646  {
647  return mechanism == other.mechanism && credentials == other.credentials;
648  }
649 
655  bool operator!=(const SaslAuthentication& other) const
656  {
657  return !operator==(other);
658  }
659  };
660 
670  LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string& name,
671  const std::string& simpleAuthentication,
672  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
673 
683  LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string& name,
684  const SaslAuthentication& saslAuthentication,
685  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
686 
690  uint32_t getVersion() const;
691 
695  std::string getName() const;
696 
701 
706  std::string getSimpleAuthentication() const;
707 
713 
714  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
715  {
716  return internalTryGet(this, method, result);
717  }
718 
719  protected:
720  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
721 
722  LdapBindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
723  Packet* packet)
724  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
725  {}
726 
727  std::string getExtendedInfoString() const override;
728 
729  private:
730  static constexpr int versionIndex = 0;
731  static constexpr int nameIndex = 1;
732  static constexpr int credentialIndex = 2;
733 
734  static constexpr int saslMechanismIndex = 0;
735  static constexpr int saslCredentialsIndex = 1;
736  };
737 
743  {
744  public:
759  LdapBindResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
760  const std::string& diagnosticMessage,
761  const std::vector<std::string>& referral = std::vector<std::string>(),
762  const std::vector<uint8_t>& serverSaslCredentials = std::vector<uint8_t>(),
763  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
764 
768  std::vector<uint8_t> getServerSaslCredentials() const;
769 
770  protected:
771  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
772 
773  static constexpr int serverSaslCredentialsTagType = 7;
774 
775  LdapBindResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
776  Packet* packet)
777  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
778  {}
779  };
780 
786  {
787  public:
794  explicit LdapUnbindRequestLayer(uint16_t messageId,
795  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
796 
797  // Unbind request has no operation record
798  Asn1ConstructedRecord* getLdapOperationAsn1Record() const = delete;
799 
801  {
803  }
804 
805  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
806  {
807  return internalTryGet(this, method, result);
808  }
809 
810  protected:
811  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
812 
813  LdapUnbindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
814  Packet* packet)
815  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
816  {}
817  };
818 
824  {
825  public:
831  {
832  public:
836  enum Value : uint8_t
837  {
861  Unknown = 255
862  };
863 
864  SearchRequestScope() = default;
865 
866  // cppcheck-suppress noExplicitConstructor
871  constexpr SearchRequestScope(Value value) : m_Value(value)
872  {}
873 
877  std::string toString() const;
878 
885  static SearchRequestScope fromUintValue(uint8_t value);
886 
887  // Allow switch and comparisons.
888  constexpr operator Value() const
889  {
890  return m_Value;
891  }
892 
893  // Prevent usage: if(LdapOperationType)
894  explicit operator bool() const = delete;
895 
896  private:
898  };
899 
905  {
906  public:
910  enum Value : uint8_t
911  {
921  Unknown = 255
922  };
923 
924  DerefAliases() = default;
925 
926  // cppcheck-suppress noExplicitConstructor
931  constexpr DerefAliases(Value value) : m_Value(value)
932  {}
933 
937  std::string toString() const;
938 
945  static DerefAliases fromUintValue(uint8_t value);
946 
947  // Allow switch and comparisons.
948  constexpr operator Value() const
949  {
950  return m_Value;
951  }
952 
953  // Prevent usage: if(LdapOperationType)
954  explicit operator bool() const = delete;
955 
956  private:
957  Value m_Value = DerefAliases::Unknown;
958  };
959 
981  LdapSearchRequestLayer(uint16_t messageId, const std::string& baseObject, SearchRequestScope scope,
982  DerefAliases derefAliases, uint8_t sizeLimit, uint8_t timeLimit, bool typesOnly,
983  Asn1Record* filterRecord, const std::vector<std::string>& attributes,
984  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
985 
989  std::string getBaseObject() const;
990 
995 
1000 
1004  uint8_t getSizeLimit() const;
1005 
1009  uint8_t getTimeLimit() const;
1010 
1017  bool getTypesOnly() const;
1018 
1024 
1028  std::vector<std::string> getAttributes() const;
1029 
1030  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
1031  {
1032  return internalTryGet(this, method, result);
1033  }
1034 
1035  protected:
1036  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1037 
1038  static constexpr int baseObjectIndex = 0;
1039  static constexpr int scopeIndex = 1;
1040  static constexpr int derefAliasIndex = 2;
1041  static constexpr int sizeLimitIndex = 3;
1042  static constexpr int timeLimitIndex = 4;
1043  static constexpr int typesOnlyIndex = 5;
1044  static constexpr int filterIndex = 6;
1045  static constexpr int attributesIndex = 7;
1046 
1047  LdapSearchRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1048  Packet* packet)
1049  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1050  {}
1051 
1052  std::string getExtendedInfoString() const override;
1053  };
1054 
1060  {
1061  public:
1070  LdapSearchResultEntryLayer(uint16_t messageId, const std::string& objectName,
1071  const std::vector<LdapAttribute>& attributes,
1072  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
1073 
1077  std::string getObjectName() const;
1078 
1082  std::vector<LdapAttribute> getAttributes() const;
1083 
1084  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
1085  {
1086  return internalTryGet(this, method, result);
1087  }
1088 
1089  protected:
1090  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1091 
1092  static constexpr int objectNameIndex = 0;
1093  static constexpr int attributesIndex = 1;
1094  static constexpr int attributeTypeIndex = 0;
1095  static constexpr int attributeValueIndex = 1;
1096 
1097  LdapSearchResultEntryLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1098  Layer* prevLayer, Packet* packet)
1099  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1100  {}
1101  };
1102 
1108  {
1109  public:
1123  LdapSearchResultDoneLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1124  const std::string& diagnosticMessage,
1125  const std::vector<std::string>& referral = std::vector<std::string>(),
1126  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1127  : LdapResponseLayer(messageId, LdapOperationType::SearchResultDone, resultCode, matchedDN,
1128  diagnosticMessage, referral, controls)
1129  {}
1130 
1131  protected:
1132  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1133 
1134  LdapSearchResultDoneLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1135  Layer* prevLayer, Packet* packet)
1136  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1137  {}
1138  };
1139 
1145  {
1146  public:
1160  LdapModifyResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1161  const std::string& diagnosticMessage,
1162  const std::vector<std::string>& referral = std::vector<std::string>(),
1163  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1164  : LdapResponseLayer(messageId, LdapOperationType::ModifyResponse, resultCode, matchedDN, diagnosticMessage,
1165  referral, controls)
1166  {}
1167 
1168  protected:
1169  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1170 
1171  LdapModifyResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1172  Packet* packet)
1173  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1174  {}
1175  };
1176 
1182  {
1183  public:
1197  LdapAddResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1198  const std::string& diagnosticMessage,
1199  const std::vector<std::string>& referral = std::vector<std::string>(),
1200  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1201  : LdapResponseLayer(messageId, LdapOperationType::AddResponse, resultCode, matchedDN, diagnosticMessage,
1202  referral, controls)
1203  {}
1204 
1205  protected:
1206  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1207 
1208  LdapAddResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1209  Packet* packet)
1210  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1211  {}
1212  };
1213 
1219  {
1220  public:
1234  LdapDeleteResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1235  const std::string& diagnosticMessage,
1236  const std::vector<std::string>& referral = std::vector<std::string>(),
1237  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1238  : LdapResponseLayer(messageId, LdapOperationType::DeleteResponse, resultCode, matchedDN, diagnosticMessage,
1239  referral, controls)
1240  {}
1241 
1242  protected:
1243  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1244 
1245  LdapDeleteResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1246  Packet* packet)
1247  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1248  {}
1249  };
1250 
1256  {
1257  public:
1271  LdapModifyDNResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1272  const std::string& diagnosticMessage,
1273  const std::vector<std::string>& referral = std::vector<std::string>(),
1274  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1275  : LdapResponseLayer(messageId, LdapOperationType::ModifyDNResponse, resultCode, matchedDN,
1276  diagnosticMessage, referral, controls)
1277  {}
1278 
1279  protected:
1280  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1281 
1282  LdapModifyDNResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1283  Layer* prevLayer, Packet* packet)
1284  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1285  {}
1286  };
1287 
1293  {
1294  public:
1308  LdapCompareResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1309  const std::string& diagnosticMessage,
1310  const std::vector<std::string>& referral = std::vector<std::string>(),
1311  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1312  : LdapResponseLayer(messageId, LdapOperationType::CompareResponse, resultCode, matchedDN, diagnosticMessage,
1313  referral, controls)
1314  {}
1315 
1316  protected:
1317  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1318 
1319  LdapCompareResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1320  Layer* prevLayer, Packet* packet)
1321  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1322  {}
1323  };
1324 } // namespace pcpp
1325 
1326 inline std::ostream& operator<<(std::ostream& os, const pcpp::LdapControl& control)
1327 {
1328  os << "{" << control.controlType << ", " << control.controlValue << "}";
1329  return os;
1330 }
1331 
1332 inline std::ostream& operator<<(std::ostream& os, const pcpp::LdapAttribute& attr)
1333 {
1334  os << "{" << attr.type << ", {";
1335 
1336  std::string separator;
1337  for (const auto& value : attr.values)
1338  {
1339  os << separator << value;
1340  if (separator.empty())
1341  {
1342  separator = ", ";
1343  }
1344  }
1345 
1346  os << "}}";
1347  return os;
1348 }
1349 
1350 inline std::ostream& operator<<(std::ostream& os,
1351  const pcpp::LdapBindRequestLayer::SaslAuthentication& saslAuthentication)
1352 {
1353  os << "{" << saslAuthentication.mechanism << ", {";
1354 
1355  std::string separator;
1356  for (const auto& value : saslAuthentication.credentials)
1357  {
1358  os << separator << "0x" << std::hex << static_cast<int>(value) << std::dec;
1359  if (separator.empty())
1360  {
1361  separator = ", ";
1362  }
1363  }
1364 
1365  os << "}}";
1366  return os;
1367 }
Definition: Asn1Codec.h:298
Definition: Asn1Codec.h:123
Definition: Asn1Codec.h:366
Definition: Layer.h:70
Definition: LdapLayer.h:1182
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:1197
Definition: LdapLayer.h:614
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
Definition: LdapLayer.h:620
@ 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:743
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:1293
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:1308
Definition: LdapLayer.h:1219
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:1234
Definition: LdapLayer.h:400
std::string toString() const override
void parseNextLayer() override
bool tryGet(Method method, ResultType &result)
Definition: LdapLayer.h:465
virtual LdapOperationType getLdapOperationType() const
std::vector< LdapControl > getControls() const
void computeCalculateFields() override
Definition: LdapLayer.h:505
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:508
size_t getHeaderLen() const override
Definition: LdapLayer.h:500
static bool isLdapPort(uint16_t port)
Definition: LdapLayer.h:475
LdapLayer(uint16_t messageId, LdapOperationType operationType, const std::vector< Asn1Record * > &messageRecords, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:1256
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:1271
Definition: LdapLayer.h:1145
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:1160
An enum wrapper class for LDAP operation types.
Definition: LdapLayer.h:22
constexpr LdapOperationType(Value value)
Definition: LdapLayer.h:82
Value
Definition: LdapLayer.h:28
@ ModifyResponse
Modify Response.
Definition: LdapLayer.h:44
@ AddResponse
Add Response.
Definition: LdapLayer.h:48
@ BindRequest
Bind Request.
Definition: LdapLayer.h:30
@ SearchResultReference
Search Result Reference.
Definition: LdapLayer.h:64
@ SearchResultEntry
Search Result Entry.
Definition: LdapLayer.h:38
@ ExtendedRequest
Extended Request.
Definition: LdapLayer.h:66
@ ModifyDNRequest
Modify DN (Distinguished Name) Request.
Definition: LdapLayer.h:54
@ DeleteResponse
Delete Response.
Definition: LdapLayer.h:52
@ CompareRequest
Compare Request.
Definition: LdapLayer.h:58
@ BindResponse
Bind Response.
Definition: LdapLayer.h:32
@ SearchRequest
Search Request.
Definition: LdapLayer.h:36
@ ModifyDNResponse
Modify DN (Distinguished Name) Response.
Definition: LdapLayer.h:56
@ ExtendedResponse
Extended Response.
Definition: LdapLayer.h:68
@ IntermediateResponse
Intermediate Response.
Definition: LdapLayer.h:70
@ ModifyRequest
Modify Request.
Definition: LdapLayer.h:42
@ CompareResponse
Compare Response.
Definition: LdapLayer.h:60
@ AddRequest
Add Request.
Definition: LdapLayer.h:46
@ AbandonRequest
Abandon Request.
Definition: LdapLayer.h:62
@ Unknown
Unknown operation type.
Definition: LdapLayer.h:72
@ DeleteRequest
Delete Request.
Definition: LdapLayer.h:50
@ SearchResultDone
Search Result Done.
Definition: LdapLayer.h:40
@ UnbindRequest
Unbind Request.
Definition: LdapLayer.h:34
std::string toString() const
static LdapOperationType fromUintValue(uint8_t value)
Definition: LdapLayer.h:556
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:116
Value
Definition: LdapLayer.h:122
@ InsufficientAccessRights
Definition: LdapLayer.h:251
@ InvalidAttributeSyntax
Definition: LdapLayer.h:219
@ AuthMethodNotSupported
Definition: LdapLayer.h:160
@ NotAllowedOnRDN
Definition: LdapLayer.h:289
@ EntryAlreadyExists
Definition: LdapLayer.h:294
@ StrongerAuthRequired
Definition: LdapLayer.h:164
@ InvalidDNSyntax
Definition: LdapLayer.h:231
@ InappropriateAuthentication
Definition: LdapLayer.h:241
@ ObjectClassViolation
Definition: LdapLayer.h:279
@ ConfidentialityRequired
Definition: LdapLayer.h:184
@ AliasProblem
Definition: LdapLayer.h:227
@ Busy
Definition: LdapLayer.h:255
@ ProtocolError
Definition: LdapLayer.h:134
@ Unavailable
Definition: LdapLayer.h:259
@ SaslBindInProgress
Definition: LdapLayer.h:189
@ InappropriateMatching
Definition: LdapLayer.h:203
@ CompareFalse
Definition: LdapLayer.h:150
@ AttributeOrValueExists
Definition: LdapLayer.h:213
@ AliasDereferencingProblem
Definition: LdapLayer.h:236
@ AdminLimitExceeded
Definition: LdapLayer.h:173
@ Referral
Definition: LdapLayer.h:169
@ SizeLimitExceeded
Definition: LdapLayer.h:145
@ UnwillingToPerform
Definition: LdapLayer.h:263
@ ConstraintViolation
Definition: LdapLayer.h:208
@ NamingViolation
Definition: LdapLayer.h:273
@ UnavailableCriticalExtension
Definition: LdapLayer.h:178
@ ObjectClassModsProhibited
Definition: LdapLayer.h:299
@ Unknown
Definition: LdapLayer.h:312
@ Other
Definition: LdapLayer.h:308
@ NoSuchAttribute
Definition: LdapLayer.h:193
@ CompareTrue
Definition: LdapLayer.h:155
@ UndefinedAttributeType
Definition: LdapLayer.h:198
@ NoSuchObject
Definition: LdapLayer.h:223
@ LoopDetect
Definition: LdapLayer.h:268
@ NotAllowedOnNonLeaf
Definition: LdapLayer.h:284
@ TimeLimitExceeded
Definition: LdapLayer.h:139
@ AffectsMultipleDSAs
Definition: LdapLayer.h:304
@ InvalidCredentials
Definition: LdapLayer.h:246
@ OperationsError
Definition: LdapLayer.h:130
@ Success
Definition: LdapLayer.h:126
std::string toString() const
constexpr LdapResultCode(Value value)
Definition: LdapLayer.h:322
static LdapResultCode fromUintValue(uint8_t value)
static DerefAliases fromUintValue(uint8_t value)
@ DerefInSearching
Dereferences aliases only after name resolution.
Definition: LdapLayer.h:915
@ DerefFindingBaseObj
Dereferences aliases only during name resolution.
Definition: LdapLayer.h:917
@ Unknown
Unknown value.
Definition: LdapLayer.h:921
@ DerefAlways
Always dereference aliases.
Definition: LdapLayer.h:919
@ NeverDerefAliases
Never dereferences aliases.
Definition: LdapLayer.h:913
constexpr DerefAliases(Value value)
Definition: LdapLayer.h:931
@ subordinateSubtree
Definition: LdapLayer.h:857
constexpr SearchRequestScope(Value value)
Definition: LdapLayer.h:871
static SearchRequestScope fromUintValue(uint8_t value)
Definition: LdapLayer.h:824
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:1108
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:1123
Definition: LdapLayer.h:1060
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:786
LdapOperationType getLdapOperationType() const override
Definition: LdapLayer.h:800
LdapUnbindRequestLayer(uint16_t messageId, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: Packet.h:27
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
Definition: ProtocolType.h:354
@ OsiModelApplicationLayer
Definition: ProtocolType.h:368
Definition: LdapLayer.h:378
std::string type
Attribute description.
Definition: LdapLayer.h:380
bool operator==(const LdapAttribute &other) const
Definition: LdapLayer.h:389
std::vector< std::string > values
A list of attribute values (zero or more)
Definition: LdapLayer.h:382
std::vector< uint8_t > credentials
Encoded SASL credentials.
Definition: LdapLayer.h:638
std::string mechanism
The SASL mechanism.
Definition: LdapLayer.h:636
bool operator!=(const SaslAuthentication &other) const
Definition: LdapLayer.h:655
bool operator==(const SaslAuthentication &other) const
Definition: LdapLayer.h:645
Definition: LdapLayer.h:356
std::string controlType
LDAP control type.
Definition: LdapLayer.h:358
bool operator==(const LdapControl &other) const
Definition: LdapLayer.h:367
std::string controlValue
LDAP control value.
Definition: LdapLayer.h:360