1 /*	$NetBSD: LDAPControl.h,v 1.1.1.2 2010/03/08 02:14:20 lukem Exp $	*/
2 
3 // OpenLDAP: pkg/ldap/contrib/ldapc++/src/LDAPControl.h,v 1.5.10.2 2008/09/03 18:03:43 quanah Exp
4 /*
5  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
6  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7  */
8 
9 
10 #ifndef LDAP_CONTROL_H
11 #define LDAP_CONTROL_H
12 #include <string>
13 #include <ldap.h>
14 
15 /**
16  * This class is used to store Controls. Controls are a mechanism to extend
17  * and modify LDAP-Operations.
18  */
19 class LDAPCtrl{
20     public :
21         /**
22          * Constructor.
23          * @param oid:  The Object Identifier of the Control
24          * @param critical: "true" if the Control should be handled
25          *                  critical by the server.
26          * @param data: If there is data for the control, put it here.
27          * @param length: The length of the data field
28          */
29         LDAPCtrl(const char *oid, bool critical=false, const char *data=0,
30                 int length=0);
31 
32         /**
33          * Constructor.
34          * @param oid:  The Object Identifier of the Control
35          * @param critical: "true" if the Control should be handled
36          *                  critical by the server.
37          * @param data: If there is data for the control, put it here.
38          */
39         LDAPCtrl(const std::string& oid, bool critical,
40                  const std::string& data);
41 
42         /**
43          * Creates a copy of the Control that "ctrl is pointing to
44          */
45         LDAPCtrl(const LDAPControl* ctrl);
46 
47         /**
48          * Destructor
49          */
50         ~LDAPCtrl();
51 
52         /**
53          * @return The OID of the control
54          */
55         std::string getOID() const;
56 
57         /**
58          * @return true if there is no "Control Value" (there is a
59          * difference between no and an empty control value)
60          */
61         bool hasData() const;
62 
63         /**
64          * @return The Data of the control as a std::string-Object
65          */
66         std::string getData() const;
67 
68         /**
69          * @return "true" if the control is critical
70          */
71         bool isCritical() const;
72 
73         /**
74          * For internal use only.
75          *
76          * Translates the control to a LDAPControl-structure as needed by
77          * the C-API
78          */
79         LDAPControl* getControlStruct() const;
80 	static void freeLDAPControlStruct(LDAPControl *ctrl);
81 
82     private :
83         std::string m_oid;
84         std::string m_data;
85         bool m_isCritical;
86         bool m_noData;
87 };
88 
89 #endif //LDAP_CONTROL_H
90