2000-09-02 02:46:32 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2001-03-15 19:07:58 +08:00
|
|
|
#include "config.h"
|
|
|
|
#include "ac/time.h"
|
2000-09-02 02:46:32 +08:00
|
|
|
#include "LDAPConstraints.h"
|
2000-10-04 02:25:34 +08:00
|
|
|
#include "LDAPControlSet.h"
|
2000-09-02 02:46:32 +08:00
|
|
|
|
2001-09-29 00:39:58 +08:00
|
|
|
using namespace std;
|
|
|
|
|
2000-09-02 02:46:32 +08:00
|
|
|
LDAPConstraints::LDAPConstraints(){
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPConstraints::LDAPConstraints()" << endl);
|
|
|
|
m_aliasDeref=LDAPConstraints::DEREF_NEVER;
|
2000-09-02 02:46:32 +08:00
|
|
|
m_maxTime=LDAP_NO_LIMIT;
|
|
|
|
m_maxSize=LDAP_NO_LIMIT;
|
2000-10-04 02:25:34 +08:00
|
|
|
m_referralChase=false;
|
|
|
|
m_HopLimit=7;
|
|
|
|
m_serverControls=0;
|
|
|
|
m_clientControls=0;
|
|
|
|
m_refRebind=0;
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LDAPConstraints::LDAPConstraints(const LDAPConstraints& c){
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPConstraints::LDAPConstraints(&)" << endl);
|
|
|
|
m_aliasDeref=c.m_aliasDeref;
|
2000-09-02 02:46:32 +08:00
|
|
|
m_maxTime=c.m_maxTime;
|
|
|
|
m_maxSize=c.m_maxSize;
|
|
|
|
m_referralChase=c.m_referralChase;
|
2000-10-04 02:25:34 +08:00
|
|
|
m_HopLimit=c.m_HopLimit;
|
|
|
|
m_deref=c.m_deref;
|
|
|
|
if(c.m_serverControls){
|
|
|
|
m_serverControls=new LDAPControlSet(*c.m_serverControls);
|
|
|
|
}else{
|
|
|
|
m_serverControls=0;
|
|
|
|
}
|
|
|
|
if(c.m_clientControls){
|
|
|
|
m_clientControls=new LDAPControlSet(*c.m_clientControls);
|
|
|
|
}else{
|
|
|
|
m_clientControls=0;
|
|
|
|
}
|
|
|
|
m_refRebind=c.m_refRebind;
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LDAPConstraints::~LDAPConstraints(){
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_DESTROY,"LDAPConstraints::~LDAPConstraints()" << endl);
|
|
|
|
delete m_clientControls;
|
|
|
|
delete m_serverControls;
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
2000-10-04 02:25:34 +08:00
|
|
|
void LDAPConstraints::setAliasDeref(int deref){
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setAliasDeref()" << endl);
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
|
|
|
|
" deref:" << deref << endl);
|
|
|
|
if( (deref == LDAPConstraints::DEREF_NEVER) ||
|
|
|
|
(deref == LDAPConstraints::DEREF_SEARCHING) ||
|
|
|
|
(deref == LDAPConstraints::DEREF_FINDING) ||
|
|
|
|
(deref == LDAPConstraints::DEREF_ALWAYS)
|
|
|
|
){
|
|
|
|
m_aliasDeref=deref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-02 02:46:32 +08:00
|
|
|
void LDAPConstraints::setMaxTime(int t){
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setMaxTime()" << endl);
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER," time:" << t << endl);
|
|
|
|
m_maxTime=t;
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LDAPConstraints::setSizeLimit(int s){
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setSizeLimit()" << endl);
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER," size:" << s << endl);
|
2000-09-02 02:46:32 +08:00
|
|
|
m_maxSize=s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LDAPConstraints::setReferralChase(bool rc){
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setReferralChase()" << endl);
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER," rc:" << rc << endl);
|
|
|
|
m_referralChase=rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LDAPConstraints::setHopLimit(int limit){
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setHopLimit()" << endl);
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
|
|
|
|
" limit:" << limit << endl);
|
|
|
|
m_HopLimit=limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LDAPConstraints::setReferralRebind(const LDAPRebind* rebind){
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setReferralRebind()" << endl);
|
|
|
|
m_refRebind = rebind;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LDAPConstraints::setServerControls(const LDAPControlSet* ctrls){
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setServerControls()" << endl);
|
|
|
|
m_serverControls=new LDAPControlSet(*ctrls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LDAPConstraints::setClientControls(const LDAPControlSet* ctrls){
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setClientControls()" << endl);
|
|
|
|
m_clientControls=new LDAPControlSet(*ctrls);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LDAPConstraints::getAliasDeref() const {
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getAliasDeref()" << endl);
|
|
|
|
return m_aliasDeref;
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int LDAPConstraints::getMaxTime() const {
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getMaxTime()" << endl);
|
2000-09-02 02:46:32 +08:00
|
|
|
return m_maxTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
int LDAPConstraints::getSizeLimit() const {
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getSizeLimit()" << endl);
|
2000-09-02 02:46:32 +08:00
|
|
|
return m_maxSize;
|
|
|
|
}
|
|
|
|
|
2000-10-04 02:25:34 +08:00
|
|
|
const LDAPRebind* LDAPConstraints::getReferralRebind() const{
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getReferralRebind()" << endl);
|
|
|
|
return m_refRebind;
|
|
|
|
}
|
|
|
|
|
|
|
|
const LDAPControlSet* LDAPConstraints::getServerControls() const{
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getServerControls()" << endl);
|
|
|
|
return m_serverControls;
|
|
|
|
}
|
|
|
|
|
|
|
|
const LDAPControlSet* LDAPConstraints::getClientControls() const{
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getClientControls()" << endl);
|
|
|
|
return m_clientControls;
|
|
|
|
}
|
|
|
|
|
2000-09-02 02:46:32 +08:00
|
|
|
LDAPControl** LDAPConstraints::getSrvCtrlsArray() const {
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getSrvCtrlsArray()" << endl);
|
|
|
|
if(m_serverControls){
|
|
|
|
return m_serverControls->toLDAPControlArray();
|
|
|
|
}else{
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LDAPControl** LDAPConstraints::getClCtrlsArray() const {
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getClCtrlsArray()" << endl);
|
|
|
|
if(m_clientControls){
|
|
|
|
return m_clientControls->toLDAPControlArray();
|
|
|
|
}else{
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-02 02:46:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
timeval* LDAPConstraints::getTimeoutStruct() const {
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getTimeoutStruct()" << endl);
|
2000-09-02 02:46:32 +08:00
|
|
|
if(m_maxTime == LDAP_NO_LIMIT){
|
|
|
|
return 0;
|
|
|
|
}else{
|
|
|
|
timeval *ret = new timeval;
|
|
|
|
ret->tv_sec=m_maxTime;
|
|
|
|
ret->tv_usec=0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LDAPConstraints::getReferralChase() const {
|
2000-10-04 02:25:34 +08:00
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getReferralChase()" << endl);
|
2000-09-02 02:46:32 +08:00
|
|
|
return m_referralChase;
|
|
|
|
}
|
|
|
|
|
2000-10-04 02:25:34 +08:00
|
|
|
int LDAPConstraints::getHopLimit() const{
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getHopLimit()" << endl);
|
|
|
|
return m_HopLimit;
|
|
|
|
}
|
|
|
|
|