2 * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
9 #include"LDAPAsynConnection.h"
10 #include "LDAPRequest.h"
11 #include "LDAPException.h"
17 LDAPResult::LDAPResult(const LDAPRequest *req, LDAPMessage *msg) :
20 DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPResult::LDAPResult()" << endl);
21 const LDAPAsynConnection *con=req->getConnection();
23 LDAPControl** srvctrls=0;
26 int err=ldap_parse_result(con->getSessionHandle(),msg,&m_resCode,
27 &matchedDN, &errMsg,&refs,&srvctrls,0);
28 if(err != LDAP_SUCCESS){
29 ber_memvfree((void**) refs);
30 ldap_controls_free(srvctrls);
31 throw LDAPException(err);
34 m_referrals=LDAPUrlList(refs);
35 ber_memvfree((void**) refs);
38 m_srvControls = LDAPControlSet(srvctrls);
40 ldap_controls_free(srvctrls);
42 m_hasControls = false;
45 m_matchedDN=string(matchedDN);
49 m_errMsg=string(errMsg);
56 LDAPResult::LDAPResult(int type, int resultCode, const std::string &msg) :
57 LDAPMsg(type,0), m_resCode(resultCode), m_errMsg(msg)
61 LDAPResult::~LDAPResult(){
62 DEBUG(LDAP_DEBUG_DESTROY,"LDAPResult::~LDAPResult()" << endl);
65 int LDAPResult::getResultCode() const{
66 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getResultCode()" << endl);
70 string LDAPResult::resToString() const{
71 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::resToString()" << endl);
72 return string(ldap_err2string(m_resCode));
75 const string& LDAPResult::getErrMsg() const{
76 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getErrMsg()" << endl);
80 const string& LDAPResult::getMatchedDN() const{
81 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getMatchedDN()" << endl);
85 const LDAPUrlList& LDAPResult::getReferralUrls() const{
86 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getReferralUrl()" << endl);
90 ostream& operator<<(ostream &s,LDAPResult &l){
91 return s << "Result: " << l.m_resCode << ": "
92 << ldap_err2string(l.m_resCode) << endl
93 << "Matched: " << l.m_matchedDN << endl << "ErrMsg: " << l.m_errMsg;