1/* $NetBSD: LDAPMessage.h,v 1.1.1.2 2010/03/08 02:14:14 lukem Exp $ */ 2 3// OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPMessage.h,v 1.4.10.3 2008/04/14 23:09:26 quanah Exp 4/* 5 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved. 6 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file 7 */ 8 9 10#ifndef LDAP_MSG_H 11#define LDAP_MSG_H 12#include <ldap.h> 13 14#include <LDAPControlSet.h> 15 16class LDAPRequest; 17/** 18 * This class represents any type of LDAP- Message returned 19 * from the server. 20 * 21 * This class is never not instantiated directly. Only 22 * its subclasses are used. The main feature of this class is the 23 * static method create() (see below) 24 */ 25class LDAPMsg{ 26 public: 27 //public Constants defining the response message types 28 static const int BIND_RESPONSE=LDAP_RES_BIND; 29 static const int SEARCH_ENTRY=LDAP_RES_SEARCH_ENTRY; 30 static const int SEARCH_DONE=LDAP_RES_SEARCH_RESULT; 31 static const int SEARCH_REFERENCE=LDAP_RES_SEARCH_REFERENCE; 32 static const int MODIFY_RESPONSE=LDAP_RES_MODIFY; 33 static const int ADD_RESPONSE=LDAP_RES_ADD; 34 static const int DEL_RESPONSE=LDAP_RES_DELETE; 35 static const int MODDN_RESPONSE=LDAP_RES_MODDN; 36 static const int COMPARE_RESPONSE=LDAP_RES_COMPARE; 37 static const int EXTENDED_RESPONSE=LDAP_RES_EXTENDED; 38 //public Constants defining the request message types 39 static const int BIND_REQUEST=LDAP_REQ_BIND; 40 static const int UNBIND_REQUEST=LDAP_REQ_UNBIND; 41 static const int SEARCH_REQUEST=LDAP_REQ_SEARCH; 42 static const int MODIFY_REQUEST=LDAP_REQ_MODIFY; 43 static const int ADD_REQUEST=LDAP_REQ_ADD; 44 static const int DELETE_REQUEST=LDAP_REQ_DELETE; 45 static const int MODRDN_REQUEST=LDAP_REQ_MODRDN; 46 static const int COMPARE_REQUEST=LDAP_REQ_COMPARE; 47 static const int ABANDON_REQUEST=LDAP_REQ_ABANDON; 48 static const int EXTENDED_REQUEST=LDAP_REQ_EXTENDED; 49 50 /** 51 * The destructor has no implemenation, because this is an abstract 52 * class. 53 */ 54 virtual ~LDAPMsg() {} 55 56 /** 57 * This method is used by the library to parse the results returned 58 * by the C-API. 59 * 60 * Based on msgtype-Value of the *msg-Parameter this method creates 61 * an Object of one of the subtypes of LDAPMsg (e.g. LDAPSearchResult 62 * or LDAPResult) that represents the same Message as the 63 * *msg-Parameter. *msg is e.g. a Message returned by the C-API's 64 * ldap_result call. 65 * @param req The LDAPRequest-object this result message is 66 * associated with. 67 * @param msg The LDAPMessage-structure from the C-API that 68 * contains the LDAP-message to parse. 69 * @return An Object of one of the subtypes of this class. It 70 * contains the parsed LDAP-message. 71 */ 72 static LDAPMsg* create(const LDAPRequest *req, LDAPMessage *msg); 73 74 /** 75 * @returns The Type of message that this object contains. Possible 76 * values are: <BR> 77 * BIND_RESPONSE <BR> 78 * SEARCH_ENTRY <BR> 79 * SEARCH_DONE <BR> 80 * SEARCH_REFERENCE <BR> 81 * MODIFY_RESPONSE <BR> 82 * ADD_RESPONSE <BR> 83 * DEL_RESPONSE <BR> 84 * MODDN_RESPONSE <BR> 85 * COMPARE_RESPONSE <BR> 86 * EXTENDED_REPONSE <BR> 87 */ 88 int getMessageType(); 89 90 /** 91 * @returns The message-ID that the C-API return for the 92 * Result-message. 93 */ 94 int getMsgID(); 95 96 /** 97 * @returns If any Control was sent back by the server this method 98 * returns true. Otherwise false is returned. 99 */ 100 bool hasControls() const; 101 102 /** 103 * @returns Server controls that were sent back by the server. 104 * @note This feature is not test well yet. 105 */ 106 const LDAPControlSet& getSrvControls() const; 107 108 protected: 109 /** 110 * This constructor make a copy of a LDAPMsg-pointer. The object 111 * itself (no the pointer) is copied. 112 * Only for internal use. 113 */ 114 LDAPMsg(LDAPMessage *msg); 115 LDAPMsg(int msgType, int msgID); 116 117 /** 118 * This attribute stores Server-Control that were returned with the 119 * message. 120 */ 121 LDAPControlSet m_srvControls; 122 123 bool m_hasControls; 124 125 private: 126 int msgType; 127 int msgID; 128}; 129#endif //ifndef LDAP_MSG_H 130