2008-03-28 07:05:10 -04:00
|
|
|
// $OpenLDAP$
|
2000-09-01 14:46:32 -04:00
|
|
|
/*
|
2016-01-29 14:32:05 -05:00
|
|
|
* Copyright 2000-2016 The OpenLDAP Foundation, All Rights Reserved.
|
2000-09-01 14:46:32 -04:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LDAP_CONTROL_H
|
|
|
|
|
#define LDAP_CONTROL_H
|
2000-10-03 14:25:34 -04:00
|
|
|
#include <string>
|
|
|
|
|
#include <ldap.h>
|
2000-09-01 14:46:32 -04:00
|
|
|
|
2001-02-19 06:34:28 -05:00
|
|
|
/**
|
|
|
|
|
* This class is used to store Controls. Controls are a mechanism to extend
|
|
|
|
|
* and modify LDAP-Operations.
|
|
|
|
|
*/
|
2000-09-01 14:46:32 -04:00
|
|
|
class LDAPCtrl{
|
2001-02-19 06:34:28 -05:00
|
|
|
public :
|
|
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
* @param oid: The Object Identifier of the Control
|
|
|
|
|
* @param critical: "true" if the Control should be handled
|
|
|
|
|
* critical by the server.
|
|
|
|
|
* @param data: If there is data for the control, put it here.
|
|
|
|
|
* @param length: The length of the data field
|
|
|
|
|
*/
|
2008-08-27 17:19:51 -04:00
|
|
|
LDAPCtrl(const char *oid, bool critical=false, const char *data=0,
|
2000-10-03 14:25:34 -04:00
|
|
|
int length=0);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor.
|
|
|
|
|
* @param oid: The Object Identifier of the Control
|
|
|
|
|
* @param critical: "true" if the Control should be handled
|
|
|
|
|
* critical by the server.
|
|
|
|
|
* @param data: If there is data for the control, put it here.
|
|
|
|
|
*/
|
2008-08-27 17:19:51 -04:00
|
|
|
LDAPCtrl(const std::string& oid, bool critical,
|
|
|
|
|
const std::string& data);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a copy of the Control that "ctrl is pointing to
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPCtrl(const LDAPControl* ctrl);
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
~LDAPCtrl();
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The OID of the control
|
|
|
|
|
*/
|
2001-09-28 12:39:58 -04:00
|
|
|
std::string getOID() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
2008-08-27 17:19:51 -04:00
|
|
|
* @return true if there is no "Control Value" (there is a
|
|
|
|
|
* difference between no and an empty control value)
|
|
|
|
|
*/
|
|
|
|
|
bool hasData() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return The Data of the control as a std::string-Object
|
2001-02-19 06:34:28 -05:00
|
|
|
*/
|
2001-09-28 12:39:58 -04:00
|
|
|
std::string getData() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return "true" if the control is critical
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
bool isCritical() const;
|
2001-02-19 06:34:28 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For internal use only.
|
|
|
|
|
*
|
|
|
|
|
* Translates the control to a LDAPControl-structure as needed by
|
|
|
|
|
* the C-API
|
|
|
|
|
*/
|
2000-10-03 14:25:34 -04:00
|
|
|
LDAPControl* getControlStruct() const;
|
2001-11-14 12:33:54 -05:00
|
|
|
static void freeLDAPControlStruct(LDAPControl *ctrl);
|
|
|
|
|
|
2000-10-03 14:25:34 -04:00
|
|
|
private :
|
2001-09-28 12:39:58 -04:00
|
|
|
std::string m_oid;
|
|
|
|
|
std::string m_data;
|
2000-10-03 14:25:34 -04:00
|
|
|
bool m_isCritical;
|
2008-08-27 17:19:51 -04:00
|
|
|
bool m_noData;
|
2000-09-01 14:46:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //LDAP_CONTROL_H
|