2008-03-28 07:05:10 -04:00
|
|
|
// $OpenLDAP$
|
2000-09-01 14:46:32 -04:00
|
|
|
/*
|
2020-01-09 11:50:21 -05:00
|
|
|
* Copyright 2000-2020 The OpenLDAP Foundation, All Rights Reserved.
|
2000-09-01 14:46:32 -04:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "LDAPMessage.h"
|
2000-10-03 14:25:34 -04:00
|
|
|
|
2000-09-01 14:46:32 -04:00
|
|
|
#include "LDAPResult.h"
|
2000-10-03 14:25:34 -04:00
|
|
|
#include "LDAPExtResult.h"
|
2007-12-20 07:33:48 -05:00
|
|
|
#include "LDAPSaslBindResult.h"
|
2000-09-01 14:46:32 -04:00
|
|
|
#include "LDAPRequest.h"
|
|
|
|
|
#include "LDAPSearchResult.h"
|
|
|
|
|
#include "LDAPSearchReference.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2001-09-28 12:39:58 -04:00
|
|
|
using namespace std;
|
|
|
|
|
|
2000-09-01 14:46:32 -04:00
|
|
|
LDAPMsg::LDAPMsg(LDAPMessage *msg){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
|
2001-02-19 06:34:28 -05:00
|
|
|
msgType=ldap_msgtype(msg);
|
2000-10-03 14:25:34 -04:00
|
|
|
m_hasControls=false;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPMsg* LDAPMsg::create(const LDAPRequest *req, LDAPMessage *msg){
|
2000-09-01 14:46:32 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::create()" << endl);
|
2001-02-19 06:34:28 -05:00
|
|
|
switch(ldap_msgtype(msg)){
|
|
|
|
|
case SEARCH_ENTRY :
|
|
|
|
|
return new LDAPSearchResult(req,msg);
|
|
|
|
|
break;
|
|
|
|
|
case SEARCH_REFERENCE :
|
|
|
|
|
return new LDAPSearchReference(req, msg);
|
|
|
|
|
break;
|
2000-10-03 14:25:34 -04:00
|
|
|
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);
|
2001-02-19 06:34:28 -05:00
|
|
|
default :
|
|
|
|
|
return new LDAPResult(req, msg);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int LDAPMsg::getMessageType(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMessageType()" << endl);
|
2001-02-19 06:34:28 -05:00
|
|
|
return msgType;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LDAPMsg::getMsgID(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMsgID()" << endl);
|
2001-02-19 06:34:28 -05:00
|
|
|
return msgID;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
bool LDAPMsg::hasControls() const{
|
|
|
|
|
return m_hasControls;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const LDAPControlSet& LDAPMsg::getSrvControls() const {
|
|
|
|
|
return m_srvControls;
|
|
|
|
|
}
|
|
|
|
|
|