Back to index

openldap  2.4.31
LDAPMessage.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #include "LDAPMessage.h"
00009 
00010 #include "LDAPResult.h"
00011 #include "LDAPExtResult.h"
00012 #include "LDAPSaslBindResult.h"
00013 #include "LDAPRequest.h"
00014 #include "LDAPSearchResult.h"
00015 #include "LDAPSearchReference.h"
00016 #include "debug.h"
00017 #include <iostream>
00018 
00019 using namespace std;
00020 
00021 LDAPMsg::LDAPMsg(LDAPMessage *msg){
00022     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
00023     msgType=ldap_msgtype(msg);
00024     m_hasControls=false;
00025 }
00026 
00027 LDAPMsg::LDAPMsg(int type, int id=0){
00028     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
00029     msgType = type;
00030     msgID = id;
00031     m_hasControls=false;
00032 }
00033 
00034 LDAPMsg* LDAPMsg::create(const LDAPRequest *req, LDAPMessage *msg){
00035     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::create()" << endl);
00036     switch(ldap_msgtype(msg)){
00037         case SEARCH_ENTRY :
00038             return new LDAPSearchResult(req,msg);
00039         break;
00040         case SEARCH_REFERENCE :
00041             return new LDAPSearchReference(req, msg);
00042         break;
00043         case EXTENDED_RESPONSE :
00044             return new LDAPExtResult(req,msg);
00045         break;
00046         case BIND_RESPONSE :
00047             return new LDAPSaslBindResult(req,msg);
00048         default :
00049             return new LDAPResult(req, msg);
00050     }
00051     return 0;
00052 }
00053 
00054 
00055 int LDAPMsg::getMessageType(){
00056     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMessageType()" << endl);
00057     return msgType;
00058 }
00059 
00060 int LDAPMsg::getMsgID(){
00061     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMsgID()" << endl);
00062     return msgID;
00063 }
00064 
00065 bool LDAPMsg::hasControls() const{
00066     return m_hasControls;
00067 }
00068 
00069 const LDAPControlSet& LDAPMsg::getSrvControls() const {
00070     return m_srvControls;
00071 }
00072