当前位置: 首页>>代码示例>>PHP>>正文


PHP Net_LDAP2::setErrorHandling方法代码示例

本文整理汇总了PHP中Net_LDAP2::setErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_LDAP2::setErrorHandling方法的具体用法?PHP Net_LDAP2::setErrorHandling怎么用?PHP Net_LDAP2::setErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_LDAP2的用法示例。


在下文中一共展示了Net_LDAP2::setErrorHandling方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: LdapInvalidCredentialsException

 function get_ldap_connection($config = null)
 {
     if ($config == null) {
         $config = $this->ldap_config;
     }
     $config_id = crc32(serialize($config));
     if (array_key_exists($config_id, self::$ldap_connections)) {
         $ldap = self::$ldap_connections[$config_id];
     } else {
         //cannot use Net_LDAP2::connect() as StatusNet uses
         //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
         //PEAR handling can be overridden on instance objects, so we do that.
         $ldap = new Net_LDAP2($config);
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err = $ldap->bind();
         if (Net_LDAP2::isError($err)) {
             // if we were called with a config, assume caller will handle
             // incorrect username/password (LDAP_INVALID_CREDENTIALS)
             if (isset($config) && $err->getCode() == 0x31) {
                 throw new LdapInvalidCredentialsException('Could not connect to LDAP server: ' . $err->getMessage());
             }
             throw new Exception('Could not connect to LDAP server: ' . $err->getMessage());
         }
         $c = common_memcache();
         if (!empty($c)) {
             $cacheObj = new MemcacheSchemaCache(array('c' => $c, 'cacheKey' => common_cache_key('ldap_schema:' . $config_id)));
             $ldap->registerSchemaCache($cacheObj);
         }
         self::$ldap_connections[$config_id] = $ldap;
     }
     return $ldap;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:32,代码来源:LdapCommon.php

示例2: Exception

 function ldap_get_connection($config = null)
 {
     if ($config == null && isset($this->default_ldap)) {
         return $this->default_ldap;
     }
     //cannot use Net_LDAP2::connect() as StatusNet uses
     //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
     //PEAR handling can be overridden on instance objects, so we do that.
     $ldap = new Net_LDAP2(isset($config) ? $config : $this->ldap_get_config());
     $ldap->setErrorHandling(PEAR_ERROR_RETURN);
     $err = $ldap->bind();
     if (Net_LDAP2::isError($err)) {
         // if we were called with a config, assume caller will handle
         // incorrect username/password (LDAP_INVALID_CREDENTIALS)
         if (isset($config) && $err->getCode() == 0x31) {
             return null;
         }
         throw new Exception('Could not connect to LDAP server: ' . $err->getMessage());
         return false;
     }
     if ($config == null) {
         $this->default_ldap = $ldap;
     }
     return $ldap;
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:25,代码来源:LdapAuthorizationPlugin.php


注:本文中的Net_LDAP2::setErrorHandling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。