]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPResult.h
use URIs instead of hostname/port
[openldap] / contrib / ldapc++ / src / LDAPResult.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #ifndef LDAP_RESULT_H
8 #define LDAP_RESULT_H
9
10 #include<iostream>
11 #include<ldap.h>
12 #include <LDAPMessage.h>
13 #include <LDAPControlSet.h>
14 #include <LDAPUrlList.h>
15
16 class LDAPRequest;
17 class LDAPAsynConnection;
18
19 /**
20  * This class is for representing LDAP-Result-Messages.
21  *
22  * It represents all Messages that were returned
23  * from LDAP-Operations except for Messages of the Type 
24  * LDAPMsg::SEARCH_ENTRY, LDAPMsg::SEARCH_REFERENCE and
25  * LDAPMsg::EXTENDED_RESPONSE. <BR>
26  * It defines a integer constant for every possible result type that can be
27  * returned by the server.
28  */
29 class LDAPResult : public LDAPMsg{
30     public :
31         //Error codes from RFC 2251
32         static const int SUCCESS                        = 0;
33         static const int OPERATIONS_ERROR               = 1;
34         static const int PROTOCOL_ERROR                 = 2;
35         static const int TIME_LIMIT_EXCEEDED            = 3;
36         static const int SIZE_LIMIT_EXCEEDED            = 4;
37         static const int COMPARE_FALSE                  = 5;
38         static const int COMPARE_TRUE                   = 6;
39         static const int AUTH_METHOD_NOT_SUPPORTED      = 7;
40         static const int STRONG_AUTH_REQUIRED           = 8;
41         
42         static const int REFERRAL                       = 10;
43         static const int ADMIN_LIMIT_EXCEEDED           = 11;
44         static const int UNAVAILABLE_CRITICAL_EXTENSION = 12;
45         static const int CONFIDENTIALITY_REQUIRED       = 13;
46         static const int SASL_BIND_IN_PROGRESS          = 14;
47         
48         static const int NO_SUCH_ATTRIBUTE              = 16;
49         static const int UNDEFINED_ATTRIBUTE_TYP        = 17;
50         static const int INAPPROPRIATE_MATCHING         = 18;
51         static const int CONSTRAINT_VIOLATION           = 19;
52         static const int ATTRIBUTE_OR_VALUE_EXISTS      = 20;
53         static const int INVALID_ATTRIBUTE_SYNTAX       = 21;
54         
55         static const int NO_SUCH_OBJECT                 = 32;
56         static const int ALIAS_PROBLEM                  = 33;
57         static const int INVALID_DN_SYNTAX              = 34;
58
59         static const int ALIAS_DEREFERENCING_PROBLEM    = 36;
60
61         static const int INAPPROPRIATE_AUTENTICATION    = 48;
62         static const int INVALID_CREDENTIALS            = 49;
63         static const int INSUFFICIENT_ACCESS            = 50;
64         static const int BUSY                           = 51;
65         static const int UNAVAILABLE                    = 52;
66         static const int UNWILLING_TO_PERFORM           = 53;
67         static const int LOOP_DETECT                    = 54;
68
69         static const int NAMING_VIOLATION               = 64;
70         static const int OBJECT_CLASS_VIOLATION         = 65;
71         static const int NOT_ALLOWED_ON_NONLEAF         = 66;
72         static const int NOT_ALLOWED_ON_RDN             = 67;
73         static const int ENTRY_ALREADY_EXISTS           = 68;
74         static const int OBJECT_CLASS_MODS_PROHIBITED   = 69;
75
76         static const int AFFECTS_MULTIPLE_DSAS          = 71;
77         
78         // some Errorcodes defined in the LDAP C API DRAFT
79         static const int OTHER                          = 80;
80         static const int SERVER_DOWN                    = 81;
81         static const int LOCAL_ERROR                    = 82;
82         static const int ENCODING_ERROR                 = 83;
83         static const int DECODING_ERROR                 = 84;
84         static const int TIMEOUT                        = 85;
85         static const int AUTH_UNKNOWN                   = 86;
86         static const int FILTER_ERROR                   = 87;
87         static const int USER_CANCELLED                 = 88;
88         static const int PARAM_ERROR                    = 89;
89         static const int NO_MEMORY                      = 90;
90         static const int CONNECT_ERROR                  = 91;
91         static const int NOT_SUPPORTED                  = 92;
92         static const int CONTROL_NOT_FOUND              = 93;
93         static const int NO_RESULTS_RETURNED            = 94;
94         static const int MORE_RESULTS_TO_RETURN         = 95;
95         static const int CLIENT_LOOP                    = 96;
96         static const int REFERRAL_LIMIT_EXCEEDED        = 97;
97
98         /**
99          * This constructor is called by the LDAPMsg::create method in
100          * order to parse a LDAPResult-Message 
101          * @param req   The request the result is associated with.
102          * @param msg   The LDAPMessage-structure that contains the
103          *              Message.
104          */
105         LDAPResult(const LDAPRequest *req, LDAPMessage *msg);
106         
107         /**
108          * The destructor.
109          */
110         virtual ~LDAPResult();
111
112         /**
113          * @returns The result code of the Message. Possible values are the
114          *      integer constants defined in this class.
115          */
116         int getResultCode() const;
117
118         /**
119          * This method transforms the result code to a human-readable
120          * result message.
121          * @returns A std::string containing the result message.
122          */
123         std::string resToString() const;
124
125         /**
126          * In some case of error the server may return addional error
127          * messages.
128          * @returns The additional error message returned by the server.
129          */
130         const std::string& getErrMsg() const;
131
132         /**
133          * For messages with a result code of: NO_SUCH_OBJECT,
134          * ALIAS_PROBLEM, ALIAS_DEREFERENCING_PROBLEM or INVALID_DN_SYNTAX
135          * the server returns the DN of deepest entry in the DIT that could
136          * be found for this operation.
137          * @returns The Matched-DN value that was returned by the server.
138          */
139         const std::string& getMatchedDN() const;
140
141         /**
142          * @returns If the result code is REFERRAL this methode returns the
143          *      URLs of the referral that was sent by the server.
144          */
145         const LDAPUrlList& getReferralUrls() const;
146
147     private :
148         int m_resCode;
149         std::string m_matchedDN;
150         std::string m_errMsg;
151         LDAPUrlList m_referrals;    
152
153     /**
154      * This method can be used to dump the data of a LDAPResult-Object.
155      * It is only useful for debugging purposes at the moment
156      */
157     friend  std::ostream& operator<<(std::ostream &s,LDAPResult &l);
158 };
159 #endif //LDAP_RESULT_H
160