1*549b59edSchristos /* $NetBSD: LDAPResult.h,v 1.3 2021/08/14 16:14:49 christos Exp $ */ 24e6df137Slukem 3d11b170bStron // $OpenLDAP$ 42de962bdSlukem /* 5*549b59edSchristos * Copyright 2000-2021 The OpenLDAP Foundation, All Rights Reserved. 62de962bdSlukem * COPYING RESTRICTIONS APPLY, see COPYRIGHT file 72de962bdSlukem */ 82de962bdSlukem 92de962bdSlukem 102de962bdSlukem #ifndef LDAP_RESULT_H 112de962bdSlukem #define LDAP_RESULT_H 122de962bdSlukem 132de962bdSlukem #include<iostream> 142de962bdSlukem #include<ldap.h> 152de962bdSlukem #include <LDAPMessage.h> 162de962bdSlukem #include <LDAPControlSet.h> 172de962bdSlukem #include <LDAPUrlList.h> 182de962bdSlukem 192de962bdSlukem class LDAPRequest; 202de962bdSlukem class LDAPAsynConnection; 212de962bdSlukem 222de962bdSlukem /** 232de962bdSlukem * This class is for representing LDAP-Result-Messages. 242de962bdSlukem * 252de962bdSlukem * It represents all Messages that were returned 262de962bdSlukem * from LDAP-Operations except for Messages of the Type 272de962bdSlukem * LDAPMsg::SEARCH_ENTRY, LDAPMsg::SEARCH_REFERENCE and 282de962bdSlukem * LDAPMsg::EXTENDED_RESPONSE. <BR> 292de962bdSlukem * It defines a integer constant for every possible result type that can be 302de962bdSlukem * returned by the server. 312de962bdSlukem */ 322de962bdSlukem class LDAPResult : public LDAPMsg{ 332de962bdSlukem public : 342de962bdSlukem //Error codes from RFC 2251 352de962bdSlukem static const int SUCCESS = 0; 362de962bdSlukem static const int OPERATIONS_ERROR = 1; 372de962bdSlukem static const int PROTOCOL_ERROR = 2; 382de962bdSlukem static const int TIME_LIMIT_EXCEEDED = 3; 392de962bdSlukem static const int SIZE_LIMIT_EXCEEDED = 4; 402de962bdSlukem static const int COMPARE_FALSE = 5; 412de962bdSlukem static const int COMPARE_TRUE = 6; 422de962bdSlukem static const int AUTH_METHOD_NOT_SUPPORTED = 7; 432de962bdSlukem static const int STRONG_AUTH_REQUIRED = 8; 442de962bdSlukem 452de962bdSlukem static const int REFERRAL = 10; 462de962bdSlukem static const int ADMIN_LIMIT_EXCEEDED = 11; 472de962bdSlukem static const int UNAVAILABLE_CRITICAL_EXTENSION = 12; 482de962bdSlukem static const int CONFIDENTIALITY_REQUIRED = 13; 492de962bdSlukem static const int SASL_BIND_IN_PROGRESS = 14; 502de962bdSlukem 512de962bdSlukem static const int NO_SUCH_ATTRIBUTE = 16; 522de962bdSlukem static const int UNDEFINED_ATTRIBUTE_TYP = 17; 532de962bdSlukem static const int INAPPROPRIATE_MATCHING = 18; 542de962bdSlukem static const int CONSTRAINT_VIOLATION = 19; 552de962bdSlukem static const int ATTRIBUTE_OR_VALUE_EXISTS = 20; 562de962bdSlukem static const int INVALID_ATTRIBUTE_SYNTAX = 21; 572de962bdSlukem 582de962bdSlukem static const int NO_SUCH_OBJECT = 32; 592de962bdSlukem static const int ALIAS_PROBLEM = 33; 602de962bdSlukem static const int INVALID_DN_SYNTAX = 34; 612de962bdSlukem 622de962bdSlukem static const int ALIAS_DEREFERENCING_PROBLEM = 36; 632de962bdSlukem 64*549b59edSchristos static const int INAPPROPRIATE_AUTHENTICATION = 48; 652de962bdSlukem static const int INVALID_CREDENTIALS = 49; 662de962bdSlukem static const int INSUFFICIENT_ACCESS = 50; 672de962bdSlukem static const int BUSY = 51; 682de962bdSlukem static const int UNAVAILABLE = 52; 692de962bdSlukem static const int UNWILLING_TO_PERFORM = 53; 702de962bdSlukem static const int LOOP_DETECT = 54; 712de962bdSlukem 722de962bdSlukem static const int NAMING_VIOLATION = 64; 732de962bdSlukem static const int OBJECT_CLASS_VIOLATION = 65; 742de962bdSlukem static const int NOT_ALLOWED_ON_NONLEAF = 66; 752de962bdSlukem static const int NOT_ALLOWED_ON_RDN = 67; 762de962bdSlukem static const int ENTRY_ALREADY_EXISTS = 68; 772de962bdSlukem static const int OBJECT_CLASS_MODS_PROHIBITED = 69; 782de962bdSlukem 792de962bdSlukem static const int AFFECTS_MULTIPLE_DSAS = 71; 802de962bdSlukem 812de962bdSlukem // some Errorcodes defined in the LDAP C API DRAFT 822de962bdSlukem static const int OTHER = 80; 832de962bdSlukem static const int SERVER_DOWN = 81; 842de962bdSlukem static const int LOCAL_ERROR = 82; 852de962bdSlukem static const int ENCODING_ERROR = 83; 862de962bdSlukem static const int DECODING_ERROR = 84; 872de962bdSlukem static const int TIMEOUT = 85; 882de962bdSlukem static const int AUTH_UNKNOWN = 86; 892de962bdSlukem static const int FILTER_ERROR = 87; 902de962bdSlukem static const int USER_CANCELLED = 88; 912de962bdSlukem static const int PARAM_ERROR = 89; 922de962bdSlukem static const int NO_MEMORY = 90; 932de962bdSlukem static const int CONNECT_ERROR = 91; 942de962bdSlukem static const int NOT_SUPPORTED = 92; 952de962bdSlukem static const int CONTROL_NOT_FOUND = 93; 962de962bdSlukem static const int NO_RESULTS_RETURNED = 94; 972de962bdSlukem static const int MORE_RESULTS_TO_RETURN = 95; 982de962bdSlukem static const int CLIENT_LOOP = 96; 992de962bdSlukem static const int REFERRAL_LIMIT_EXCEEDED = 97; 1002de962bdSlukem 1012de962bdSlukem /** 1022de962bdSlukem * This constructor is called by the LDAPMsg::create method in 1032de962bdSlukem * order to parse a LDAPResult-Message 1042de962bdSlukem * @param req The request the result is associated with. 1052de962bdSlukem * @param msg The LDAPMessage-structure that contains the 1062de962bdSlukem * Message. 1072de962bdSlukem */ 1082de962bdSlukem LDAPResult(const LDAPRequest *req, LDAPMessage *msg); 1092de962bdSlukem LDAPResult(int type, int resultCode, const std::string &msg); 1102de962bdSlukem 1112de962bdSlukem /** 1122de962bdSlukem * The destructor. 1132de962bdSlukem */ 1142de962bdSlukem virtual ~LDAPResult(); 1152de962bdSlukem 1162de962bdSlukem /** 1172de962bdSlukem * @returns The result code of the Message. Possible values are the 1182de962bdSlukem * integer constants defined in this class. 1192de962bdSlukem */ 1202de962bdSlukem int getResultCode() const; 1212de962bdSlukem 1222de962bdSlukem /** 1232de962bdSlukem * This method transforms the result code to a human-readable 1242de962bdSlukem * result message. 1252de962bdSlukem * @returns A std::string containing the result message. 1262de962bdSlukem */ 1272de962bdSlukem std::string resToString() const; 1282de962bdSlukem 1292de962bdSlukem /** 130*549b59edSchristos * In some case of error the server may return additional error 1312de962bdSlukem * messages. 1322de962bdSlukem * @returns The additional error message returned by the server. 1332de962bdSlukem */ 1342de962bdSlukem const std::string& getErrMsg() const; 1352de962bdSlukem 1362de962bdSlukem /** 1372de962bdSlukem * For messages with a result code of: NO_SUCH_OBJECT, 1382de962bdSlukem * ALIAS_PROBLEM, ALIAS_DEREFERENCING_PROBLEM or INVALID_DN_SYNTAX 1392de962bdSlukem * the server returns the DN of deepest entry in the DIT that could 1402de962bdSlukem * be found for this operation. 1412de962bdSlukem * @returns The Matched-DN value that was returned by the server. 1422de962bdSlukem */ 1432de962bdSlukem const std::string& getMatchedDN() const; 1442de962bdSlukem 1452de962bdSlukem /** 146*549b59edSchristos * @returns If the result code is REFERRAL this method returns the 1472de962bdSlukem * URLs of the referral that was sent by the server. 1482de962bdSlukem */ 1492de962bdSlukem const LDAPUrlList& getReferralUrls() const; 1502de962bdSlukem 1512de962bdSlukem private : 1522de962bdSlukem int m_resCode; 1532de962bdSlukem std::string m_matchedDN; 1542de962bdSlukem std::string m_errMsg; 1552de962bdSlukem LDAPUrlList m_referrals; 1562de962bdSlukem 1572de962bdSlukem /** 1582de962bdSlukem * This method can be used to dump the data of a LDAPResult-Object. 1592de962bdSlukem * It is only useful for debugging purposes at the moment 1602de962bdSlukem */ 1612de962bdSlukem friend std::ostream& operator<<(std::ostream &s,LDAPResult &l); 1622de962bdSlukem }; 1632de962bdSlukem #endif //LDAP_RESULT_H 1642de962bdSlukem 165