|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Ldap |
|
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
19 * @version $Id: Exception.php 22996 2010-09-22 17:01:46Z sgehrig $ |
|
20 */ |
|
21 |
|
22 /** |
|
23 * @see Zend_Exception |
|
24 */ |
|
25 require_once 'Zend/Exception.php'; |
|
26 |
|
27 /** |
|
28 * @category Zend |
|
29 * @package Zend_Ldap |
|
30 * @uses Zend_Exception |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 */ |
|
34 class Zend_Ldap_Exception extends Zend_Exception |
|
35 { |
|
36 const LDAP_SUCCESS = 0x00; |
|
37 const LDAP_OPERATIONS_ERROR = 0x01; |
|
38 const LDAP_PROTOCOL_ERROR = 0x02; |
|
39 const LDAP_TIMELIMIT_EXCEEDED = 0x03; |
|
40 const LDAP_SIZELIMIT_EXCEEDED = 0x04; |
|
41 const LDAP_COMPARE_FALSE = 0x05; |
|
42 const LDAP_COMPARE_TRUE = 0x06; |
|
43 const LDAP_AUTH_METHOD_NOT_SUPPORTED = 0x07; |
|
44 const LDAP_STRONG_AUTH_REQUIRED = 0x08; |
|
45 const LDAP_PARTIAL_RESULTS = 0x09; |
|
46 const LDAP_REFERRAL = 0x0a; |
|
47 const LDAP_ADMINLIMIT_EXCEEDED = 0x0b; |
|
48 const LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 0x0c; |
|
49 const LDAP_CONFIDENTIALITY_REQUIRED = 0x0d; |
|
50 const LDAP_SASL_BIND_IN_PROGRESS = 0x0e; |
|
51 const LDAP_NO_SUCH_ATTRIBUTE = 0x10; |
|
52 const LDAP_UNDEFINED_TYPE = 0x11; |
|
53 const LDAP_INAPPROPRIATE_MATCHING = 0x12; |
|
54 const LDAP_CONSTRAINT_VIOLATION = 0x13; |
|
55 const LDAP_TYPE_OR_VALUE_EXISTS = 0x14; |
|
56 const LDAP_INVALID_SYNTAX = 0x15; |
|
57 const LDAP_NO_SUCH_OBJECT = 0x20; |
|
58 const LDAP_ALIAS_PROBLEM = 0x21; |
|
59 const LDAP_INVALID_DN_SYNTAX = 0x22; |
|
60 const LDAP_IS_LEAF = 0x23; |
|
61 const LDAP_ALIAS_DEREF_PROBLEM = 0x24; |
|
62 const LDAP_PROXY_AUTHZ_FAILURE = 0x2F; |
|
63 const LDAP_INAPPROPRIATE_AUTH = 0x30; |
|
64 const LDAP_INVALID_CREDENTIALS = 0x31; |
|
65 const LDAP_INSUFFICIENT_ACCESS = 0x32; |
|
66 const LDAP_BUSY = 0x33; |
|
67 const LDAP_UNAVAILABLE = 0x34; |
|
68 const LDAP_UNWILLING_TO_PERFORM = 0x35; |
|
69 const LDAP_LOOP_DETECT = 0x36; |
|
70 const LDAP_NAMING_VIOLATION = 0x40; |
|
71 const LDAP_OBJECT_CLASS_VIOLATION = 0x41; |
|
72 const LDAP_NOT_ALLOWED_ON_NONLEAF = 0x42; |
|
73 const LDAP_NOT_ALLOWED_ON_RDN = 0x43; |
|
74 const LDAP_ALREADY_EXISTS = 0x44; |
|
75 const LDAP_NO_OBJECT_CLASS_MODS = 0x45; |
|
76 const LDAP_RESULTS_TOO_LARGE = 0x46; |
|
77 const LDAP_AFFECTS_MULTIPLE_DSAS = 0x47; |
|
78 const LDAP_OTHER = 0x50; |
|
79 const LDAP_SERVER_DOWN = 0x51; |
|
80 const LDAP_LOCAL_ERROR = 0x52; |
|
81 const LDAP_ENCODING_ERROR = 0x53; |
|
82 const LDAP_DECODING_ERROR = 0x54; |
|
83 const LDAP_TIMEOUT = 0x55; |
|
84 const LDAP_AUTH_UNKNOWN = 0x56; |
|
85 const LDAP_FILTER_ERROR = 0x57; |
|
86 const LDAP_USER_CANCELLED = 0x58; |
|
87 const LDAP_PARAM_ERROR = 0x59; |
|
88 const LDAP_NO_MEMORY = 0x5a; |
|
89 const LDAP_CONNECT_ERROR = 0x5b; |
|
90 const LDAP_NOT_SUPPORTED = 0x5c; |
|
91 const LDAP_CONTROL_NOT_FOUND = 0x5d; |
|
92 const LDAP_NO_RESULTS_RETURNED = 0x5e; |
|
93 const LDAP_MORE_RESULTS_TO_RETURN = 0x5f; |
|
94 const LDAP_CLIENT_LOOP = 0x60; |
|
95 const LDAP_REFERRAL_LIMIT_EXCEEDED = 0x61; |
|
96 const LDAP_CUP_RESOURCES_EXHAUSTED = 0x71; |
|
97 const LDAP_CUP_SECURITY_VIOLATION = 0x72; |
|
98 const LDAP_CUP_INVALID_DATA = 0x73; |
|
99 const LDAP_CUP_UNSUPPORTED_SCHEME = 0x74; |
|
100 const LDAP_CUP_RELOAD_REQUIRED = 0x75; |
|
101 const LDAP_CANCELLED = 0x76; |
|
102 const LDAP_NO_SUCH_OPERATION = 0x77; |
|
103 const LDAP_TOO_LATE = 0x78; |
|
104 const LDAP_CANNOT_CANCEL = 0x79; |
|
105 const LDAP_ASSERTION_FAILED = 0x7A; |
|
106 const LDAP_SYNC_REFRESH_REQUIRED = 0x1000; |
|
107 const LDAP_X_SYNC_REFRESH_REQUIRED = 0x4100; |
|
108 const LDAP_X_NO_OPERATION = 0x410e; |
|
109 const LDAP_X_ASSERTION_FAILED = 0x410f; |
|
110 const LDAP_X_NO_REFERRALS_FOUND = 0x4110; |
|
111 const LDAP_X_CANNOT_CHAIN = 0x4111; |
|
112 |
|
113 /* internal error code constants */ |
|
114 |
|
115 const LDAP_X_DOMAIN_MISMATCH = 0x7001; |
|
116 const LDAP_X_EXTENSION_NOT_LOADED = 0x7002; |
|
117 |
|
118 /** |
|
119 * @param Zend_Ldap $ldap A Zend_Ldap object |
|
120 * @param string $str An informtive exception message |
|
121 * @param int $code An LDAP error code |
|
122 */ |
|
123 public function __construct(Zend_Ldap $ldap = null, $str = null, $code = 0) |
|
124 { |
|
125 $errorMessages = array(); |
|
126 $message = ''; |
|
127 if ($ldap !== null) { |
|
128 $oldCode = $code; |
|
129 $message = $ldap->getLastError($code, $errorMessages) . ': '; |
|
130 if ($code === 0) { |
|
131 $message = ''; |
|
132 $code = $oldCode; |
|
133 } |
|
134 } |
|
135 if (empty($message)) { |
|
136 if ($code > 0) { |
|
137 $message = '0x' . dechex($code) . ': '; |
|
138 } |
|
139 } |
|
140 |
|
141 if (!empty($str)) { |
|
142 $message .= $str; |
|
143 } else { |
|
144 $message .= 'no exception message'; |
|
145 } |
|
146 |
|
147 parent::__construct($message, $code); |
|
148 } |
|
149 |
|
150 |
|
151 /** |
|
152 * @deprecated not necessary any more - will be removed |
|
153 * @param Zend_Ldap $ldap A Zend_Ldap object |
|
154 * @return int The current error code for the resource |
|
155 */ |
|
156 public static function getLdapCode(Zend_Ldap $ldap = null) |
|
157 { |
|
158 if ($ldap !== null) { |
|
159 return $ldap->getLastErrorCode(); |
|
160 } |
|
161 return 0; |
|
162 } |
|
163 |
|
164 /** |
|
165 * @deprecated will be removed |
|
166 * @return int The current error code for this exception |
|
167 */ |
|
168 public function getErrorCode() |
|
169 { |
|
170 return $this->getCode(); |
|
171 } |
|
172 } |