]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPMessage.cpp
initial support for SASL
[openldap] / contrib / ldapc++ / src / LDAPMessage.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #include "LDAPMessage.h"
8
9 #include "LDAPResult.h"
10 #include "LDAPExtResult.h"
11 #include "LDAPSaslBindResult.h"
12 #include "LDAPRequest.h"
13 #include "LDAPSearchResult.h"
14 #include "LDAPSearchReference.h"
15 #include "debug.h"
16 #include <iostream>
17
18 using namespace std;
19
20 LDAPMsg::LDAPMsg(LDAPMessage *msg){
21     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
22     msgType=ldap_msgtype(msg);
23     m_hasControls=false;
24 }
25
26 LDAPMsg::LDAPMsg(int type, int id=0){
27     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
28     msgType = type;
29     msgID = id;
30     m_hasControls=false;
31 }
32
33 LDAPMsg* LDAPMsg::create(const LDAPRequest *req, LDAPMessage *msg){
34     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::create()" << endl);
35     switch(ldap_msgtype(msg)){
36         case SEARCH_ENTRY :
37             return new LDAPSearchResult(req,msg);
38         break;
39         case SEARCH_REFERENCE :
40             return new LDAPSearchReference(req, msg);
41         break;
42         case EXTENDED_RESPONSE :
43             return new LDAPExtResult(req,msg);
44         break;
45         case BIND_RESPONSE :
46             return new LDAPSaslBindResult(req,msg);
47         default :
48             return new LDAPResult(req, msg);
49     }
50     return 0;
51 }
52
53
54 int LDAPMsg::getMessageType(){
55     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMessageType()" << endl);
56     return msgType;
57 }
58
59 int LDAPMsg::getMsgID(){
60     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMsgID()" << endl);
61     return msgID;
62 }
63
64 bool LDAPMsg::hasControls() const{
65     return m_hasControls;
66 }
67
68 const LDAPControlSet& LDAPMsg::getSrvControls() const {
69     return m_srvControls;
70 }
71