3 * Copyright 2000-2011 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9 #include "LDAPRequest.h"
13 LDAPRequest::LDAPRequest(){
14 DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPRequest::LDAPRequest()" << endl);
17 LDAPRequest::LDAPRequest(const LDAPRequest& req){
18 DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPRequest::LDAPRequest(&)" << endl);
19 m_isReferral=req.m_isReferral;
20 m_cons = new LDAPConstraints(*(req.m_cons));
21 m_connection = req.m_connection;
22 m_parent = req.m_parent;
23 m_hopCount = req.m_hopCount;
24 m_msgID = req.m_msgID;
27 LDAPRequest::LDAPRequest(LDAPAsynConnection* con,
28 const LDAPConstraints* cons,bool isReferral, const LDAPRequest* parent){
29 DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPRequest::LDAPRequest()" << endl);
32 m_cons=new LDAPConstraints( *(con->getConstraints()) );
34 m_cons=new LDAPConstraints( *cons);
36 m_isReferral=isReferral;
38 m_hopCount = (parent->getHopCount()+1);
46 LDAPRequest::~LDAPRequest(){
47 DEBUG(LDAP_DEBUG_DESTROY,"LDAPRequest::~LDAPRequest()" << endl);
51 LDAPMsg* LDAPRequest::getNextMessage() const
53 DEBUG(LDAP_DEBUG_DESTROY,"LDAPRequest::getNextMessage()" << endl);
57 res=ldap_result(this->m_connection->getSessionHandle(),
58 this->m_msgID,0,0,&msg);
64 throw LDAPException(this->m_connection);
67 //this can throw an exception (Decoding Error)
68 ret = LDAPMsg::create(this,msg);
74 LDAPRequest* LDAPRequest::followReferral(LDAPMsg* /*urls*/){
75 DEBUG(LDAP_DEBUG_TRACE,"LDAPBindRequest::followReferral()" << endl);
76 DEBUG(LDAP_DEBUG_TRACE,
77 "ReferralChasing not implemented for this operation" << endl);
81 const LDAPConstraints* LDAPRequest::getConstraints() const{
82 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getConstraints()" << endl);
86 const LDAPAsynConnection* LDAPRequest::getConnection() const{
87 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getConnection()" << endl);
91 int LDAPRequest::getType() const {
92 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getType()" << endl);
96 int LDAPRequest::getMsgID() const {
97 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getMsgId()" << endl);
101 int LDAPRequest::getHopCount() const {
102 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getHopCount()" << endl);
106 const LDAPRequest* LDAPRequest::getParent() const{
107 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getParent()" << endl);
111 bool LDAPRequest::isReferral() const {
112 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::isReferral()" << endl);
116 bool LDAPRequest::equals(const LDAPRequest* req) const{
117 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::equals()" << endl);
118 if( (this->m_requestType == req->getType()) &&
119 (this->m_connection->getHost() == req->m_connection->getHost()) &&
120 (this->m_connection->getPort() == req->m_connection->getPort())
126 bool LDAPRequest::isCycle() const{
127 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::isCycle()" << endl);
128 const LDAPRequest* parent=m_parent;
131 if(this->equals(parent)){
134 parent=parent->getParent();
142 void LDAPRequest::unbind() const{
143 DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::unbind()" << endl);
144 m_connection->unbind();