summaryrefslogtreecommitdiffstats
path: root/contrib/ldapc++/src/LDAPMessage.cpp
blob: 041c0e06a40356d7c25b35c3e52ff8f209637adb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// $OpenLDAP$
/*
 * Copyright 2000-2024 The OpenLDAP Foundation, All Rights Reserved.
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */


#include "LDAPMessage.h"

#include "LDAPResult.h"
#include "LDAPExtResult.h"
#include "LDAPSaslBindResult.h"
#include "LDAPRequest.h"
#include "LDAPSearchResult.h"
#include "LDAPSearchReference.h"
#include "debug.h"
#include <iostream>

using namespace std;

LDAPMsg::LDAPMsg(LDAPMessage *msg){
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
    msgType=ldap_msgtype(msg);
    m_hasControls=false;
}

LDAPMsg::LDAPMsg(int type, int id=0){
    DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
    msgType = type;
    msgID = id;
    m_hasControls=false;
}

LDAPMsg* LDAPMsg::create(const LDAPRequest *req, LDAPMessage *msg){
    DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::create()" << endl);
    switch(ldap_msgtype(msg)){
        case SEARCH_ENTRY :
            return new LDAPSearchResult(req,msg);
        break;
        case SEARCH_REFERENCE :
            return new LDAPSearchReference(req, msg);
        break;
        case EXTENDED_RESPONSE :
            return new LDAPExtResult(req,msg);
        break;
        case BIND_RESPONSE :
            return new LDAPSaslBindResult(req,msg);
        default :
            return new LDAPResult(req, msg);
    }
    return 0;
}


int LDAPMsg::getMessageType(){
    DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMessageType()" << endl);
    return msgType;
}

int LDAPMsg::getMsgID(){
    DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMsgID()" << endl);
    return msgID;
}

bool LDAPMsg::hasControls() const{
    return m_hasControls;
}

const LDAPControlSet& LDAPMsg::getSrvControls() const {
    return m_srvControls;
}