openldap/contrib/ldapc++/src/LDAPMessage.cpp

73 lines
1.7 KiB
C++
Raw Normal View History

2008-03-28 07:05:10 -04:00
// $OpenLDAP$
/*
2018-03-22 11:35:24 -04:00
* Copyright 2000-2018 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "LDAPMessage.h"
#include "LDAPResult.h"
#include "LDAPExtResult.h"
2007-12-20 07:33:48 -05:00
#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;
}
2007-12-20 07:33:48 -05:00
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;
2007-12-20 07:33:48 -05:00
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;
}