2000-09-01 14:46:32 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "LDAPEntry.h"
|
|
|
|
|
|
2006-10-10 10:25:00 -04:00
|
|
|
#include "LDAPAsynConnection.h"
|
2000-10-03 14:25:34 -04:00
|
|
|
#include "LDAPException.h"
|
|
|
|
|
|
2001-09-28 12:39:58 -04:00
|
|
|
using namespace std;
|
|
|
|
|
|
2000-09-01 14:46:32 -04:00
|
|
|
LDAPEntry::LDAPEntry(const LDAPEntry& entry){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry(&)" << endl);
|
|
|
|
|
m_dn=entry.m_dn;
|
|
|
|
|
m_attrs=new LDAPAttributeList( *(entry.m_attrs));
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPEntry::LDAPEntry(const string& dn, const LDAPAttributeList *attrs){
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl);
|
|
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT | LDAP_DEBUG_PARAMETER,
|
|
|
|
|
" dn:" << dn << endl << " attrs:" << *attrs << endl);
|
|
|
|
|
m_attrs=new LDAPAttributeList(*attrs);
|
|
|
|
|
m_dn=dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPEntry::LDAPEntry(const LDAPAsynConnection *ld, LDAPMessage *msg){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPEntry::LDAPEntry()" << endl);
|
|
|
|
|
char* tmp=ldap_get_dn(ld->getSessionHandle(),msg);
|
|
|
|
|
m_dn=string(tmp);
|
2002-04-23 11:28:11 -04:00
|
|
|
ldap_memfree(tmp);
|
2000-10-03 14:25:34 -04:00
|
|
|
m_attrs = new LDAPAttributeList(ld, msg);
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDAPEntry::~LDAPEntry(){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_DESTROY,"LDAPEntry::~LDAPEntry()" << endl);
|
|
|
|
|
delete m_attrs;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
void LDAPEntry::setDN(const string& dn){
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::setDN()" << endl);
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
|
|
|
|
|
" dn:" << dn << endl);
|
|
|
|
|
m_dn=dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LDAPEntry::setAttributes(LDAPAttributeList *attrs){
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::setAttributes()" << endl);
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
|
|
|
|
|
" attrs:" << *attrs << endl);
|
|
|
|
|
if (m_attrs != 0){
|
|
|
|
|
delete m_attrs;
|
|
|
|
|
}
|
|
|
|
|
m_attrs=attrs;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2002-04-23 11:28:11 -04:00
|
|
|
const string& LDAPEntry::getDN() const{
|
2000-10-03 14:25:34 -04:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::getDN()" << endl);
|
|
|
|
|
return m_dn;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
const LDAPAttributeList* LDAPEntry::getAttributes() const{
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPEntry::getAttributes()" << endl);
|
|
|
|
|
return m_attrs;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostream& operator << (ostream& s, const LDAPEntry& le){
|
2000-10-03 14:25:34 -04:00
|
|
|
s << "DN: " << le.m_dn << ": " << *(le.m_attrs);
|
|
|
|
|
return s;
|
2000-09-01 14:46:32 -04:00
|
|
|
}
|