PcapPlusPlus  Next
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() override = default;
414 
420 
426 
430  uint16_t getMessageID() const;
431 
436  std::vector<LdapControl> getControls() const;
437 
443 
464  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
465  {
466  return internalTryGet(this, method, result);
467  }
468 
474  static bool isLdapPort(uint16_t port)
475  {
476  return port == 389;
477  }
478 
487  static LdapLayer* parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
488 
489  // implement abstract methods
490 
494  void parseNextLayer() override;
495 
499  size_t getHeaderLen() const override
500  {
501  return m_Asn1Record->getTotalLength();
502  }
503 
504  void computeCalculateFields() override
505  {}
506 
508  {
510  }
511 
512  std::string toString() const override;
513 
514  protected:
515  std::unique_ptr<Asn1Record> m_Asn1Record;
516 
517  LdapLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
518  Packet* packet);
519  LdapLayer() = default;
520  void init(uint16_t messageId, LdapOperationType operationType, const std::vector<Asn1Record*>& messageRecords,
521  const std::vector<LdapControl>& controls);
522  virtual std::string getExtendedInfoString() const
523  {
524  return "";
525  }
526 
527  static constexpr int messageIdIndex = 0;
528  static constexpr int operationTypeIndex = 1;
529  static constexpr int controlsIndex = 2;
530 
531  static constexpr int controlTypeIndex = 0;
532  static constexpr int controlValueIndex = 1;
533 
534  template <typename LdapClass, typename Method, typename ResultType>
535  bool internalTryGet(LdapClass* thisPtr, Method method, ResultType& result)
536  {
537  try
538  {
539  result = std::mem_fn(method)(thisPtr);
540  return true;
541  }
542  catch (...)
543  {
544  return false;
545  }
546  }
547  };
548 
555  {
556  public:
561 
566  std::string getMatchedDN() const;
567 
572  std::string getDiagnosticMessage() const;
573 
578  std::vector<std::string> getReferral() const;
579 
580  protected:
581  static constexpr int resultCodeIndex = 0;
582  static constexpr int matchedDNIndex = 1;
583  static constexpr int diagnotsticsMessageIndex = 2;
584  static constexpr int referralIndex = 3;
585 
586  static constexpr uint8_t referralTagType = 3;
587 
588  LdapResponseLayer() = default;
589  LdapResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
590  Packet* packet)
591  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
592  {}
593 
594  LdapResponseLayer(uint16_t messageId, LdapOperationType operationType, LdapResultCode resultCode,
595  const std::string& matchedDN, const std::string& diagnosticMessage,
596  const std::vector<std::string>& referral = std::vector<std::string>(),
597  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
598 
599  void init(uint16_t messageId, LdapOperationType operationType, LdapResultCode resultCode,
600  const std::string& matchedDN, const std::string& diagnosticMessage,
601  const std::vector<std::string>& referral = std::vector<std::string>(),
602  const std::vector<Asn1Record*>& additionalRecords = std::vector<Asn1Record*>(),
603  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
604 
605  std::string getExtendedInfoString() const override;
606  };
607 
613  {
614  public:
618  enum class AuthenticationType : uint8_t
619  {
621  Simple = 0,
623  Sasl = 3,
625  NotApplicable = 255
626  };
627 
633  {
635  std::string mechanism;
637  std::vector<uint8_t> credentials;
638 
644  bool operator==(const SaslAuthentication& other) const
645  {
646  return mechanism == other.mechanism && credentials == other.credentials;
647  }
648 
654  bool operator!=(const SaslAuthentication& other) const
655  {
656  return !operator==(other);
657  }
658  };
659 
669  LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string& name,
670  const std::string& simpleAuthentication,
671  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
672 
682  LdapBindRequestLayer(uint16_t messageId, uint8_t version, const std::string& name,
683  const SaslAuthentication& saslAuthentication,
684  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
685 
689  uint32_t getVersion() const;
690 
694  std::string getName() const;
695 
700 
705  std::string getSimpleAuthentication() const;
706 
712 
713  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
714  {
715  return internalTryGet(this, method, result);
716  }
717 
718  protected:
719  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
720 
721  LdapBindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
722  Packet* packet)
723  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
724  {}
725 
726  std::string getExtendedInfoString() const override;
727 
728  private:
729  static constexpr int versionIndex = 0;
730  static constexpr int nameIndex = 1;
731  static constexpr int credentialIndex = 2;
732 
733  static constexpr int saslMechanismIndex = 0;
734  static constexpr int saslCredentialsIndex = 1;
735  };
736 
742  {
743  public:
758  LdapBindResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
759  const std::string& diagnosticMessage,
760  const std::vector<std::string>& referral = std::vector<std::string>(),
761  const std::vector<uint8_t>& serverSaslCredentials = std::vector<uint8_t>(),
762  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
763 
767  std::vector<uint8_t> getServerSaslCredentials() const;
768 
769  protected:
770  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
771 
772  static constexpr int serverSaslCredentialsTagType = 7;
773 
774  LdapBindResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
775  Packet* packet)
776  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
777  {}
778  };
779 
785  {
786  public:
793  explicit LdapUnbindRequestLayer(uint16_t messageId,
794  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
795 
796  // Unbind request has no operation record
797  Asn1ConstructedRecord* getLdapOperationAsn1Record() const = delete;
798 
800  {
802  }
803 
804  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
805  {
806  return internalTryGet(this, method, result);
807  }
808 
809  protected:
810  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
811 
812  LdapUnbindRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
813  Packet* packet)
814  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
815  {}
816  };
817 
823  {
824  public:
830  {
831  public:
835  enum Value : uint8_t
836  {
860  Unknown = 255
861  };
862 
863  SearchRequestScope() = default;
864 
865  // cppcheck-suppress noExplicitConstructor
870  constexpr SearchRequestScope(Value value) : m_Value(value)
871  {}
872 
876  std::string toString() const;
877 
884  static SearchRequestScope fromUintValue(uint8_t value);
885 
886  // Allow switch and comparisons.
887  constexpr operator Value() const
888  {
889  return m_Value;
890  }
891 
892  // Prevent usage: if(LdapOperationType)
893  explicit operator bool() const = delete;
894 
895  private:
897  };
898 
904  {
905  public:
909  enum Value : uint8_t
910  {
920  Unknown = 255
921  };
922 
923  DerefAliases() = default;
924 
925  // cppcheck-suppress noExplicitConstructor
930  constexpr DerefAliases(Value value) : m_Value(value)
931  {}
932 
936  std::string toString() const;
937 
944  static DerefAliases fromUintValue(uint8_t value);
945 
946  // Allow switch and comparisons.
947  constexpr operator Value() const
948  {
949  return m_Value;
950  }
951 
952  // Prevent usage: if(LdapOperationType)
953  explicit operator bool() const = delete;
954 
955  private:
956  Value m_Value = DerefAliases::Unknown;
957  };
958 
980  LdapSearchRequestLayer(uint16_t messageId, const std::string& baseObject, SearchRequestScope scope,
981  DerefAliases derefAliases, uint8_t sizeLimit, uint8_t timeLimit, bool typesOnly,
982  Asn1Record* filterRecord, const std::vector<std::string>& attributes,
983  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
984 
988  std::string getBaseObject() const;
989 
994 
999 
1003  uint8_t getSizeLimit() const;
1004 
1008  uint8_t getTimeLimit() const;
1009 
1016  bool getTypesOnly() const;
1017 
1023 
1027  std::vector<std::string> getAttributes() const;
1028 
1029  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
1030  {
1031  return internalTryGet(this, method, result);
1032  }
1033 
1034  protected:
1035  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1036 
1037  static constexpr int baseObjectIndex = 0;
1038  static constexpr int scopeIndex = 1;
1039  static constexpr int derefAliasIndex = 2;
1040  static constexpr int sizeLimitIndex = 3;
1041  static constexpr int timeLimitIndex = 4;
1042  static constexpr int typesOnlyIndex = 5;
1043  static constexpr int filterIndex = 6;
1044  static constexpr int attributesIndex = 7;
1045 
1046  LdapSearchRequestLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1047  Packet* packet)
1048  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1049  {}
1050 
1051  std::string getExtendedInfoString() const override;
1052  };
1053 
1059  {
1060  public:
1069  LdapSearchResultEntryLayer(uint16_t messageId, const std::string& objectName,
1070  const std::vector<LdapAttribute>& attributes,
1071  const std::vector<LdapControl>& controls = std::vector<LdapControl>());
1072 
1076  std::string getObjectName() const;
1077 
1081  std::vector<LdapAttribute> getAttributes() const;
1082 
1083  template <typename Method, typename ResultType> bool tryGet(Method method, ResultType& result)
1084  {
1085  return internalTryGet(this, method, result);
1086  }
1087 
1088  protected:
1089  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1090 
1091  static constexpr int objectNameIndex = 0;
1092  static constexpr int attributesIndex = 1;
1093  static constexpr int attributeTypeIndex = 0;
1094  static constexpr int attributeValueIndex = 1;
1095 
1096  LdapSearchResultEntryLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1097  Layer* prevLayer, Packet* packet)
1098  : LdapLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1099  {}
1100  };
1101 
1107  {
1108  public:
1122  LdapSearchResultDoneLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1123  const std::string& diagnosticMessage,
1124  const std::vector<std::string>& referral = std::vector<std::string>(),
1125  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1126  : LdapResponseLayer(messageId, LdapOperationType::SearchResultDone, resultCode, matchedDN,
1127  diagnosticMessage, referral, controls)
1128  {}
1129 
1130  protected:
1131  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1132 
1133  LdapSearchResultDoneLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1134  Layer* prevLayer, Packet* packet)
1135  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1136  {}
1137  };
1138 
1144  {
1145  public:
1159  LdapModifyResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1160  const std::string& diagnosticMessage,
1161  const std::vector<std::string>& referral = std::vector<std::string>(),
1162  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1163  : LdapResponseLayer(messageId, LdapOperationType::ModifyResponse, resultCode, matchedDN, diagnosticMessage,
1164  referral, controls)
1165  {}
1166 
1167  protected:
1168  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1169 
1170  LdapModifyResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1171  Packet* packet)
1172  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1173  {}
1174  };
1175 
1181  {
1182  public:
1196  LdapAddResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1197  const std::string& diagnosticMessage,
1198  const std::vector<std::string>& referral = std::vector<std::string>(),
1199  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1200  : LdapResponseLayer(messageId, LdapOperationType::AddResponse, resultCode, matchedDN, diagnosticMessage,
1201  referral, controls)
1202  {}
1203 
1204  protected:
1205  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1206 
1207  LdapAddResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1208  Packet* packet)
1209  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1210  {}
1211  };
1212 
1218  {
1219  public:
1233  LdapDeleteResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1234  const std::string& diagnosticMessage,
1235  const std::vector<std::string>& referral = std::vector<std::string>(),
1236  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1237  : LdapResponseLayer(messageId, LdapOperationType::DeleteResponse, resultCode, matchedDN, diagnosticMessage,
1238  referral, controls)
1239  {}
1240 
1241  protected:
1242  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1243 
1244  LdapDeleteResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen, Layer* prevLayer,
1245  Packet* packet)
1246  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1247  {}
1248  };
1249 
1255  {
1256  public:
1270  LdapModifyDNResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1271  const std::string& diagnosticMessage,
1272  const std::vector<std::string>& referral = std::vector<std::string>(),
1273  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1274  : LdapResponseLayer(messageId, LdapOperationType::ModifyDNResponse, resultCode, matchedDN,
1275  diagnosticMessage, referral, controls)
1276  {}
1277 
1278  protected:
1279  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1280 
1281  LdapModifyDNResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1282  Layer* prevLayer, Packet* packet)
1283  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1284  {}
1285  };
1286 
1292  {
1293  public:
1307  LdapCompareResponseLayer(uint16_t messageId, LdapResultCode resultCode, const std::string& matchedDN,
1308  const std::string& diagnosticMessage,
1309  const std::vector<std::string>& referral = std::vector<std::string>(),
1310  const std::vector<LdapControl>& controls = std::vector<LdapControl>())
1311  : LdapResponseLayer(messageId, LdapOperationType::CompareResponse, resultCode, matchedDN, diagnosticMessage,
1312  referral, controls)
1313  {}
1314 
1315  protected:
1316  friend LdapLayer* LdapLayer::parseLdapMessage(uint8_t* data, size_t dataLen, Layer* prevLayer, Packet* packet);
1317 
1318  LdapCompareResponseLayer(std::unique_ptr<Asn1Record> asn1Record, uint8_t* data, size_t dataLen,
1319  Layer* prevLayer, Packet* packet)
1320  : LdapResponseLayer(std::move(asn1Record), data, dataLen, prevLayer, packet)
1321  {}
1322  };
1323 } // namespace pcpp
1324 
1325 inline std::ostream& operator<<(std::ostream& os, const pcpp::LdapControl& control)
1326 {
1327  os << "{" << control.controlType << ", " << control.controlValue << "}";
1328  return os;
1329 }
1330 
1331 inline std::ostream& operator<<(std::ostream& os, const pcpp::LdapAttribute& attr)
1332 {
1333  os << "{" << attr.type << ", {";
1334 
1335  std::string separator;
1336  for (const auto& value : attr.values)
1337  {
1338  os << separator << value;
1339  if (separator.empty())
1340  {
1341  separator = ", ";
1342  }
1343  }
1344 
1345  os << "}}";
1346  return os;
1347 }
1348 
1349 inline std::ostream& operator<<(std::ostream& os,
1350  const pcpp::LdapBindRequestLayer::SaslAuthentication& saslAuthentication)
1351 {
1352  os << "{" << saslAuthentication.mechanism << ", {";
1353 
1354  std::string separator;
1355  for (const auto& value : saslAuthentication.credentials)
1356  {
1357  os << separator << "0x" << std::hex << static_cast<int>(value) << std::dec;
1358  if (separator.empty())
1359  {
1360  separator = ", ";
1361  }
1362  }
1363 
1364  os << "}}";
1365  return os;
1366 }
Definition: Asn1Codec.h:298
Definition: Asn1Codec.h:123
Definition: Asn1Codec.h:366
Definition: Layer.h:69
Definition: LdapLayer.h:1181
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:1196
Definition: LdapLayer.h:613
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:619
@ 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:742
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:1292
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:1307
Definition: LdapLayer.h:1218
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:1233
Definition: LdapLayer.h:400
std::string toString() const override
void parseNextLayer() override
bool tryGet(Method method, ResultType &result)
Definition: LdapLayer.h:464
virtual LdapOperationType getLdapOperationType() const
std::vector< LdapControl > getControls() const
void computeCalculateFields() override
Definition: LdapLayer.h:504
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:507
size_t getHeaderLen() const override
Definition: LdapLayer.h:499
static bool isLdapPort(uint16_t port)
Definition: LdapLayer.h:474
LdapLayer(uint16_t messageId, LdapOperationType operationType, const std::vector< Asn1Record * > &messageRecords, const std::vector< LdapControl > &controls=std::vector< LdapControl >())
Definition: LdapLayer.h:1255
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:1270
Definition: LdapLayer.h:1144
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:1159
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:555
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:914
@ DerefFindingBaseObj
Dereferences aliases only during name resolution.
Definition: LdapLayer.h:916
@ Unknown
Unknown value.
Definition: LdapLayer.h:920
@ DerefAlways
Always dereference aliases.
Definition: LdapLayer.h:918
@ NeverDerefAliases
Never dereferences aliases.
Definition: LdapLayer.h:912
constexpr DerefAliases(Value value)
Definition: LdapLayer.h:930
@ subordinateSubtree
Definition: LdapLayer.h:856
constexpr SearchRequestScope(Value value)
Definition: LdapLayer.h:870
static SearchRequestScope fromUintValue(uint8_t value)
Definition: LdapLayer.h:823
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:1107
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:1122
Definition: LdapLayer.h:1059
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:785
LdapOperationType getLdapOperationType() const override
Definition: LdapLayer.h:799
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:364
@ OsiModelApplicationLayer
Definition: ProtocolType.h:378
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:637
std::string mechanism
The SASL mechanism.
Definition: LdapLayer.h:635
bool operator!=(const SaslAuthentication &other) const
Definition: LdapLayer.h:654
bool operator==(const SaslAuthentication &other) const
Definition: LdapLayer.h:644
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