File indexing completed on 2024-05-19 06:03:13

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Ldap
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * @see Zend_Exception
0024  */
0025 // require_once 'Zend/Exception.php';
0026 
0027 /**
0028  * @category   Zend
0029  * @package    Zend_Ldap
0030  * @uses       Zend_Exception
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  */
0034 class Zend_Ldap_Exception extends Zend_Exception
0035 {
0036     const LDAP_SUCCESS                        = 0x00;
0037     const LDAP_OPERATIONS_ERROR               = 0x01;
0038     const LDAP_PROTOCOL_ERROR                 = 0x02;
0039     const LDAP_TIMELIMIT_EXCEEDED             = 0x03;
0040     const LDAP_SIZELIMIT_EXCEEDED             = 0x04;
0041     const LDAP_COMPARE_FALSE                  = 0x05;
0042     const LDAP_COMPARE_TRUE                   = 0x06;
0043     const LDAP_AUTH_METHOD_NOT_SUPPORTED      = 0x07;
0044     const LDAP_STRONG_AUTH_REQUIRED           = 0x08;
0045     const LDAP_PARTIAL_RESULTS                = 0x09;
0046     const LDAP_REFERRAL                       = 0x0a;
0047     const LDAP_ADMINLIMIT_EXCEEDED            = 0x0b;
0048     const LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 0x0c;
0049     const LDAP_CONFIDENTIALITY_REQUIRED       = 0x0d;
0050     const LDAP_SASL_BIND_IN_PROGRESS          = 0x0e;
0051     const LDAP_NO_SUCH_ATTRIBUTE              = 0x10;
0052     const LDAP_UNDEFINED_TYPE                 = 0x11;
0053     const LDAP_INAPPROPRIATE_MATCHING         = 0x12;
0054     const LDAP_CONSTRAINT_VIOLATION           = 0x13;
0055     const LDAP_TYPE_OR_VALUE_EXISTS           = 0x14;
0056     const LDAP_INVALID_SYNTAX                 = 0x15;
0057     const LDAP_NO_SUCH_OBJECT                 = 0x20;
0058     const LDAP_ALIAS_PROBLEM                  = 0x21;
0059     const LDAP_INVALID_DN_SYNTAX              = 0x22;
0060     const LDAP_IS_LEAF                        = 0x23;
0061     const LDAP_ALIAS_DEREF_PROBLEM            = 0x24;
0062     const LDAP_PROXY_AUTHZ_FAILURE            = 0x2F;
0063     const LDAP_INAPPROPRIATE_AUTH             = 0x30;
0064     const LDAP_INVALID_CREDENTIALS            = 0x31;
0065     const LDAP_INSUFFICIENT_ACCESS            = 0x32;
0066     const LDAP_BUSY                           = 0x33;
0067     const LDAP_UNAVAILABLE                    = 0x34;
0068     const LDAP_UNWILLING_TO_PERFORM           = 0x35;
0069     const LDAP_LOOP_DETECT                    = 0x36;
0070     const LDAP_NAMING_VIOLATION               = 0x40;
0071     const LDAP_OBJECT_CLASS_VIOLATION         = 0x41;
0072     const LDAP_NOT_ALLOWED_ON_NONLEAF         = 0x42;
0073     const LDAP_NOT_ALLOWED_ON_RDN             = 0x43;
0074     const LDAP_ALREADY_EXISTS                 = 0x44;
0075     const LDAP_NO_OBJECT_CLASS_MODS           = 0x45;
0076     const LDAP_RESULTS_TOO_LARGE              = 0x46;
0077     const LDAP_AFFECTS_MULTIPLE_DSAS          = 0x47;
0078     const LDAP_OTHER                          = 0x50;
0079     const LDAP_SERVER_DOWN                    = 0x51;
0080     const LDAP_LOCAL_ERROR                    = 0x52;
0081     const LDAP_ENCODING_ERROR                 = 0x53;
0082     const LDAP_DECODING_ERROR                 = 0x54;
0083     const LDAP_TIMEOUT                        = 0x55;
0084     const LDAP_AUTH_UNKNOWN                   = 0x56;
0085     const LDAP_FILTER_ERROR                   = 0x57;
0086     const LDAP_USER_CANCELLED                 = 0x58;
0087     const LDAP_PARAM_ERROR                    = 0x59;
0088     const LDAP_NO_MEMORY                      = 0x5a;
0089     const LDAP_CONNECT_ERROR                  = 0x5b;
0090     const LDAP_NOT_SUPPORTED                  = 0x5c;
0091     const LDAP_CONTROL_NOT_FOUND              = 0x5d;
0092     const LDAP_NO_RESULTS_RETURNED            = 0x5e;
0093     const LDAP_MORE_RESULTS_TO_RETURN         = 0x5f;
0094     const LDAP_CLIENT_LOOP                    = 0x60;
0095     const LDAP_REFERRAL_LIMIT_EXCEEDED        = 0x61;
0096     const LDAP_CUP_RESOURCES_EXHAUSTED        = 0x71;
0097     const LDAP_CUP_SECURITY_VIOLATION         = 0x72;
0098     const LDAP_CUP_INVALID_DATA               = 0x73;
0099     const LDAP_CUP_UNSUPPORTED_SCHEME         = 0x74;
0100     const LDAP_CUP_RELOAD_REQUIRED            = 0x75;
0101     const LDAP_CANCELLED                      = 0x76;
0102     const LDAP_NO_SUCH_OPERATION              = 0x77;
0103     const LDAP_TOO_LATE                       = 0x78;
0104     const LDAP_CANNOT_CANCEL                  = 0x79;
0105     const LDAP_ASSERTION_FAILED               = 0x7A;
0106     const LDAP_SYNC_REFRESH_REQUIRED          = 0x1000;
0107     const LDAP_X_SYNC_REFRESH_REQUIRED        = 0x4100;
0108     const LDAP_X_NO_OPERATION                 = 0x410e;
0109     const LDAP_X_ASSERTION_FAILED             = 0x410f;
0110     const LDAP_X_NO_REFERRALS_FOUND           = 0x4110;
0111     const LDAP_X_CANNOT_CHAIN                 = 0x4111;
0112 
0113     /* internal error code constants */
0114 
0115     const LDAP_X_DOMAIN_MISMATCH              = 0x7001;
0116     const LDAP_X_EXTENSION_NOT_LOADED         = 0x7002;
0117 
0118     /**
0119      * @param Zend_Ldap $ldap A Zend_Ldap object
0120      * @param string    $str  An informtive exception message
0121      * @param int       $code An LDAP error code
0122      */
0123     public function __construct(Zend_Ldap $ldap = null, $str = null, $code = 0)
0124     {
0125         $errorMessages = array();
0126         $message = '';
0127         if ($ldap !== null) {
0128             $oldCode = $code;
0129             $message = $ldap->getLastError($code, $errorMessages) . ': ';
0130             if ($code === 0) {
0131                 $message = '';
0132                 $code = $oldCode;
0133             }
0134         }
0135         if (empty($message)) {
0136             if ($code > 0) {
0137                 $message = '0x' . dechex($code) . ': ';
0138             }
0139         }
0140 
0141         if (!empty($str)) {
0142             $message .= $str;
0143         } else {
0144             $message .= 'no exception message';
0145         }
0146 
0147         parent::__construct($message, $code);
0148     }
0149 
0150 
0151     /**
0152      * @deprecated not necessary any more - will be removed
0153      * @param Zend_Ldap $ldap A Zend_Ldap object
0154      * @return int The current error code for the resource
0155      */
0156     public static function getLdapCode(Zend_Ldap $ldap = null)
0157     {
0158         if ($ldap !== null) {
0159             return $ldap->getLastErrorCode();
0160         }
0161         return 0;
0162     }
0163 
0164     /**
0165      * @deprecated will be removed
0166      * @return int The current error code for this exception
0167      */
0168     public function getErrorCode()
0169     {
0170         return $this->getCode();
0171     }
0172 }