Back to index

openldap  2.4.31
LDAPConstraints.cpp
Go to the documentation of this file.
00001 // $OpenLDAP$
00002 /*
00003  * Copyright 2000-2012 The OpenLDAP Foundation, All Rights Reserved.
00004  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
00005  */
00006 
00007 
00008 #include "debug.h"
00009 #include "config.h"
00010 #include "ac/time.h"
00011 #include "LDAPConstraints.h"
00012 #include "LDAPControlSet.h"
00013 
00014 using namespace std;
00015 
00016 LDAPConstraints::LDAPConstraints(){
00017     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPConstraints::LDAPConstraints()" << endl);
00018     m_aliasDeref=LDAPConstraints::DEREF_NEVER;
00019        m_maxTime=LDAP_NO_LIMIT;
00020        m_maxSize=LDAP_NO_LIMIT;
00021        m_referralChase=false;
00022     m_HopLimit=7;
00023     m_serverControls=0;
00024     m_clientControls=0;
00025     m_refRebind=0;
00026 }
00027 
00028 LDAPConstraints::LDAPConstraints(const LDAPConstraints& c){
00029     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPConstraints::LDAPConstraints(&)" << endl);
00030     m_aliasDeref=c.m_aliasDeref;
00031     m_maxTime=c.m_maxTime;
00032     m_maxSize=c.m_maxSize;
00033     m_referralChase=c.m_referralChase;
00034     m_HopLimit=c.m_HopLimit;
00035     m_deref=c.m_deref;
00036     if(c.m_serverControls){
00037         m_serverControls=new LDAPControlSet(*c.m_serverControls);
00038     }else{
00039         m_serverControls=0;
00040     }
00041     if(c.m_clientControls){
00042         m_clientControls=new LDAPControlSet(*c.m_clientControls);
00043     }else{
00044         m_clientControls=0;
00045     }
00046     m_refRebind=c.m_refRebind;
00047 }
00048 
00049 LDAPConstraints::~LDAPConstraints(){
00050     DEBUG(LDAP_DEBUG_DESTROY,"LDAPConstraints::~LDAPConstraints()" << endl);
00051     delete m_clientControls;
00052     delete m_serverControls;
00053 }
00054 
00055 void LDAPConstraints::setAliasDeref(int deref){
00056     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setAliasDeref()" << endl);
00057     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
00058             "   deref:" << deref << endl);
00059     if( (deref == LDAPConstraints::DEREF_NEVER) || 
00060             (deref == LDAPConstraints::DEREF_SEARCHING) ||
00061             (deref == LDAPConstraints::DEREF_FINDING) ||
00062             (deref == LDAPConstraints::DEREF_ALWAYS) 
00063         ){
00064         m_aliasDeref=deref;
00065     }
00066 }
00067         
00068 
00069 void LDAPConstraints::setMaxTime(int t){
00070     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setMaxTime()" << endl);
00071     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,"   time:" << t << endl);
00072     m_maxTime=t;
00073 }
00074 
00075 void LDAPConstraints::setSizeLimit(int s){
00076     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setSizeLimit()" << endl);
00077     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,"   size:" << s << endl);
00078        m_maxSize=s;
00079 }
00080 
00081 void LDAPConstraints::setReferralChase(bool rc){
00082     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setReferralChase()" << endl);
00083     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,"   rc:" << rc << endl);
00084     m_referralChase=rc;
00085 }
00086 
00087 void LDAPConstraints::setHopLimit(int limit){
00088     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setHopLimit()" << endl);
00089     DEBUG(LDAP_DEBUG_TRACE | LDAP_DEBUG_PARAMETER,
00090             "   limit:" << limit << endl);
00091     m_HopLimit=limit;
00092 }
00093 
00094 void LDAPConstraints::setReferralRebind(const LDAPRebind* rebind){
00095     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setReferralRebind()" << endl);
00096     m_refRebind = rebind;
00097 }
00098 
00099 void LDAPConstraints::setServerControls(const LDAPControlSet* ctrls){
00100     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setServerControls()" << endl);
00101     m_serverControls=new LDAPControlSet(*ctrls);
00102 }
00103 
00104 void LDAPConstraints::setClientControls(const LDAPControlSet* ctrls){
00105     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::setClientControls()" << endl);
00106     m_clientControls=new LDAPControlSet(*ctrls);
00107 }
00108 
00109 int LDAPConstraints::getAliasDeref() const {
00110     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getAliasDeref()" << endl);
00111     return m_aliasDeref;
00112 }
00113 
00114 int LDAPConstraints::getMaxTime() const {
00115     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getMaxTime()" << endl);
00116        return m_maxTime;
00117 }
00118 
00119 int LDAPConstraints::getSizeLimit() const {
00120     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getSizeLimit()" << endl);
00121        return m_maxSize;
00122 }
00123 
00124 const LDAPRebind* LDAPConstraints::getReferralRebind() const{
00125     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getReferralRebind()" << endl);
00126     return m_refRebind;
00127 }
00128 
00129 const LDAPControlSet* LDAPConstraints::getServerControls() const{
00130     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getServerControls()" << endl);
00131     return m_serverControls;
00132 }
00133 
00134 const LDAPControlSet* LDAPConstraints::getClientControls() const{
00135     DEBUG(LDAP_DEBUG_TRACE,"LDAPConstraints::getClientControls()" << endl);
00136     return m_clientControls;
00137 }
00138 
00139 LDAPControl** LDAPConstraints::getSrvCtrlsArray() const {
00140     DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getSrvCtrlsArray()" << endl);
00141     if(m_serverControls){
00142         return m_serverControls->toLDAPControlArray();
00143     }else{
00144         return 0;
00145     }
00146 }
00147 
00148 LDAPControl** LDAPConstraints::getClCtrlsArray() const {
00149     DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getClCtrlsArray()" << endl);
00150     if(m_clientControls){
00151         return m_clientControls->toLDAPControlArray(); 
00152     }else{
00153         return 0;
00154     }
00155 }
00156 
00157 timeval* LDAPConstraints::getTimeoutStruct() const {
00158     DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getTimeoutStruct()" << endl);
00159     if(m_maxTime == LDAP_NO_LIMIT){
00160         return 0;
00161     }else{
00162         timeval *ret = new timeval;
00163         ret->tv_sec=m_maxTime;
00164         ret->tv_usec=0;
00165         return ret;
00166     }
00167 }
00168 
00169 bool LDAPConstraints::getReferralChase() const {
00170     DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getReferralChase()" << endl);
00171        return m_referralChase;
00172 }
00173 
00174 int LDAPConstraints::getHopLimit() const{
00175     DEBUG(LDAP_DEBUG_TRACE,"LDAPContstraints::getHopLimit()" << endl);
00176     return m_HopLimit;
00177 }
00178