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"
15 LDAPResult::LDAPResult(const LDAPRequest *req, LDAPMessage *msg) :
18 DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPResult::LDAPResult()" << endl);
19 const LDAPAsynConnection *con=req->getConnection();
21 LDAPControl** srvctrls=0;
24 int err=ldap_parse_result(con->getSessionHandle(),msg,&m_resCode,
25 &matchedDN, &errMsg,&refs,&srvctrls,0);
26 if(err != LDAP_SUCCESS){
27 ber_memvfree((void**) refs);
28 ldap_controls_free(srvctrls);
29 throw LDAPException(err);
32 m_referrals=LDAPUrlList(refs);
33 ber_memvfree((void**) refs);
36 m_srvControls = LDAPControlSet(srvctrls);
38 ldap_controls_free(srvctrls);
40 m_hasControls = false;
43 m_matchedDN=string(matchedDN);
47 m_errMsg=string(errMsg);
54 LDAPResult::~LDAPResult(){
55 DEBUG(LDAP_DEBUG_DESTROY,"LDAPResult::~LDAPResult()" << endl);
58 int LDAPResult::getResultCode() const{
59 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getResultCode()" << endl);
63 string LDAPResult::resToString() const{
64 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::resToString()" << endl);
65 return string(ldap_err2string(m_resCode));
68 const string& LDAPResult::getErrMsg() const{
69 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getErrMsg()" << endl);
73 const string& LDAPResult::getMatchedDN() const{
74 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getMatchedDN()" << endl);
78 const LDAPUrlList& LDAPResult::getReferralUrls() const{
79 DEBUG(LDAP_DEBUG_TRACE,"LDAPResult::getReferralUrl()" << endl);
83 ostream& operator<<(ostream &s,LDAPResult &l){
84 return s << "Result: " << l.m_resCode << ": "
85 << ldap_err2string(l.m_resCode) << endl
86 << "Matched: " << l.m_matchedDN << endl << "ErrMsg: " << l.m_errMsg;