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


PHP ldap_errno函数代码示例

本文整理汇总了PHP中ldap_errno函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_errno函数的具体用法?PHP ldap_errno怎么用?PHP ldap_errno使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: loadPage

 protected function loadPage()
 {
     if (!ldap_control_paged_result($this->connection, $this->pageSize, true, $this->pageToken)) {
         throw new SearchException("Unable to set paged control pageSize: " . $this->pageSize);
     }
     $search = ldap_search($this->connection, $this->baseDn, $this->filter, is_array($this->attributes) ? $this->attributes : []);
     if (!$search) {
         // Something went wrong in search
         throw Connection::createLdapSearchException(ldap_errno($this->connection), $this->baseDn, $this->filter, $this->pageSize);
     }
     $this->entries = ldap_get_entries($this->connection, $search);
     $this->entriesPosition = 0;
     if (!$this->entries) {
         throw Connection::createLdapSearchException(ldap_errno($this->connection), $this->baseDn, $this->filter, $this->pageSize);
     }
     // check if on first page
     if (empty($this->pageToken)) {
         $this->currentPage = 0;
     } else {
         $this->currentPage++;
     }
     // Ok go to next page
     ldap_control_paged_result_response($this->connection, $search, $this->pageToken);
     if (empty($this->pageToken)) {
         $this->isLastPage = true;
     }
 }
开发者ID:81square,项目名称:ldap,代码行数:27,代码来源:SearchIterator.php

示例2: connect

 /**
  * Tries to connect to an LDAP server.
  *
  * If a connection is currently open, it is closed.
  *
  * All PHP errors triggered by ldap_* calls are wrapped in exceptions and thrown.
  *
  * @param string $serverHostName The hostname of the LDAP server.
  * @param int $port The server port to use.
  * @param int $timeout The timeout in seconds of the network connection.
  * @throws Exception If an error occurs during the `ldap_connect` call or if there is a connection
  *                   issue during the subsequent anonymous bind.
  */
 public function connect($serverHostName, $port = ServerInfo::DEFAULT_LDAP_PORT, $timeout = self::DEFAULT_TIMEOUT_SECS)
 {
     $this->closeIfCurrentlyOpen();
     Log::debug("Calling ldap_connect('%s', %s)", $serverHostName, $port);
     $this->connectionResource = ldap_connect($serverHostName, $port);
     ldap_set_option($this->connectionResource, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($this->connectionResource, LDAP_OPT_REFERRALS, 0);
     ldap_set_option($this->connectionResource, LDAP_OPT_NETWORK_TIMEOUT, $timeout);
     Log::debug("ldap_connect result is %s", $this->connectionResource);
     // ldap_connect will not always try to connect to the server, so execute a bind
     // to test the connection
     try {
         ldap_bind($this->connectionResource);
         Log::debug("anonymous ldap_bind call finished; connection ok");
     } catch (Exception $ex) {
         // if the error was due to a connection error, rethrow, otherwise ignore it
         $errno = ldap_errno($this->connectionResource);
         Log::debug("anonymous ldap_bind returned error '%s'", $errno);
         if (!in_array($errno, self::$initialBindErrorCodesToIgnore)) {
             throw $ex;
         }
     }
     if (!$this->isOpen()) {
         // sanity check
         throw new Exception("sanity check failed: ldap_connect did not return a connection resource!");
     }
 }
开发者ID:polytan02,项目名称:dev_piwik_ynh,代码行数:40,代码来源:Client.php

示例3: _processLogin

 /**
  * 
  * Verifies a username handle and password.
  * 
  * @return mixed An array of verified user information, or boolean false
  * if verification failed.
  * 
  * 
  */
 protected function _processLogin()
 {
     // connect
     $conn = @ldap_connect($this->_config['uri']);
     // did the connection work?
     if (!$conn) {
         throw $this->_exception('ERR_CONNECTION_FAILED', $this->_config);
     }
     // upgrade to LDAP3 when possible
     @ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
     // filter the handle to prevent LDAP injection
     $regex = '/[^' . $this->_config['filter'] . ']/';
     $this->_handle = preg_replace($regex, '', $this->_handle);
     // bind to the server
     $rdn = sprintf($this->_config['format'], $this->_handle);
     $bind = @ldap_bind($conn, $rdn, $this->_passwd);
     // did the bind succeed?
     if ($bind) {
         ldap_close($conn);
         return array('handle' => $this->_handle);
     } else {
         $this->_err = @ldap_errno($conn) . " " . @ldap_error($conn);
         ldap_close($conn);
         return false;
     }
 }
开发者ID:agentile,项目名称:foresmo,代码行数:35,代码来源:Ldap.php

示例4: __construct

 public function __construct($message, $ldapLink, $dn = null)
 {
     if ($ldapLink instanceof server) {
         $ldapLink = $ldapLink->getLink();
     }
     parent::__construct(sprintf('LDAP exception (%s): %s (%s)', $dn ? $dn : 'global', $message, @ldap_error($ldapLink), @ldap_errno($ldapLink)));
 }
开发者ID:cepharum,项目名称:txf,代码行数:7,代码来源:protocol_exception.php

示例5: install_etape_ldap4_dist

function install_etape_ldap4_dist()
{
    $adresse_ldap = _request('adresse_ldap');
    $login_ldap = _request('login_ldap');
    $pass_ldap = _request('pass_ldap');
    $port_ldap = _request('port_ldap');
    $base_ldap = _request('base_ldap');
    $base_ldap_text = _request('base_ldap_text');
    if (!$base_ldap) {
        $base_ldap = $base_ldap_text;
    }
    echo install_debut_html();
    $ldap_link = ldap_connect($adresse_ldap, $port_ldap);
    @ldap_bind($ldap_link, $login_ldap, $pass_ldap);
    // Essayer de verifier le chemin fourni
    $r = @ldap_compare($ldap_link, $base_ldap, "objectClass", "");
    $fail = ldap_errno($ldap_link) == 32;
    if ($fail) {
        echo info_etape(_T('info_chemin_acces_annuaire')), info_progression_etape(3, 'etape_ldap', 'install/', true), "<div class='error'><p><b>" . _T('avis_operation_echec') . "</b></p><p>" . _T('avis_chemin_invalide_1'), " (<tt>" . htmlspecialchars($base_ldap) . "</tt>) " . _T('avis_chemin_invalide_2') . "</p></div>";
    } else {
        info_etape(_T('info_reglage_ldap'));
        echo info_progression_etape(4, 'etape_ldap', 'install/');
        $statuts = liste_statuts_ldap();
        $statut_ldap = defined('_INSTALL_STATUT_LDAP') ? _INSTALL_STATUT_LDAP : $GLOBALS['liste_des_statuts']['info_redacteurs'];
        $res = install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) . "<input type='hidden' name='etape' value='ldap5' />" . "<input type='hidden' name='base_ldap' value='" . htmlentities($base_ldap) . "' />" . fieldset(_T('info_statut_utilisateurs_1'), array('statut_ldap' => array('label' => _T('info_statut_utilisateurs_2') . '<br />', 'valeur' => $statut_ldap, 'alternatives' => $statuts))) . install_ldap_correspondances() . bouton_suivant();
        echo generer_form_ecrire('install', $res);
    }
    echo install_fin_html();
}
开发者ID:nursit,项目名称:SPIP,代码行数:29,代码来源:etape_ldap4.php

示例6: parse

 /**
  * @return string[]
  * @throws ValueRetrievalFailureException
  */
 public function parse()
 {
     if (!ldap_parse_reference($this->link, $this->reference, $referrals)) {
         throw new ValueRetrievalFailureException(ldap_error($this->link), ldap_errno($this->link));
     }
     return $referrals;
 }
开发者ID:daverandom,项目名称:ldapi,代码行数:11,代码来源:Reference.php

示例7: getFirstEntry

 /**
  * Returns the first entry in the result set.
  * 
  * @throws \gossi\ldap\LdapException If the read fails.
  * @return \gossi\ldap\LdapEntry The new LdapEntry.
  */
 public function getFirstEntry()
 {
     $this->pointer = ldap_first_entry($this->conn, $this->result);
     if (ldap_errno($this->conn)) {
         throw new LdapException(ldap_error($this->conn), ldap_errno($this->conn));
     }
     return new LdapEntry($this->conn, $this->pointer);
 }
开发者ID:gossi,项目名称:ldap,代码行数:14,代码来源:LdapResult.php

示例8: __construct

 function __construct($arg, $code = 0)
 {
     if (is_resource($arg)) {
         $errno = ldap_errno($arg);
         $msg = ldap_err2str($errno);
     } else {
         $errno = $code;
         $msg = $arg;
     }
     error_log("LDAP Error {$errno}: {$msg}");
     parent::__construct($msg, $errno);
 }
开发者ID:btalayminaei,项目名称:DGSecurity,代码行数:12,代码来源:ldap.php

示例9: __construct

 public function __construct($message, $ldap = NULL)
 {
     if (is_resource($ldap)) {
         $error = ldap_error($ldap);
         if ($error) {
             parent::__construct($message . '. ' . $error, ldap_errno($ldap));
         } else {
             parent::__construct($message);
         }
     } else {
         parent::__construct($message);
     }
 }
开发者ID:jacekkow,项目名称:qa-cas-ldap-auth,代码行数:13,代码来源:ldap.php

示例10: fetch

 /**
  * 
  * Fetch roles for a user.
  * 
  * @param string $handle Username to get roles for.
  * 
  * @return array An array of roles discovered in LDAP.
  * 
  */
 public function fetch($handle)
 {
     // connect
     $conn = @ldap_connect($this->_config['url']);
     // did the connection work?
     if (!$conn) {
         throw $this->_exception('ERR_CONNECTION_FAILED', array('url' => $this->_config['url']));
     }
     // upgrade to LDAP3 when possible
     @ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
     // bind to the server
     if ($this->_config['binddn']) {
         // authenticated bind
         $bind = @ldap_bind($conn, $this->_config['binddn'], $this->_config['bindpw']);
     } else {
         // anonumous bind
         $bind = @ldap_bind($conn);
     }
     // did we bind to the server?
     if (!$bind) {
         // not using $this->_exception() because we need fine control
         // over the error text
         throw Solar::exception(get_class($this), @ldap_errno($conn), @ldap_error($conn), array($this->_config));
     }
     // search for the groups
     $filter = sprintf($this->_config['filter'], $handle);
     $attrib = (array) $this->_config['attrib'];
     $result = ldap_search($conn, $this->_config['basedn'], $filter, $attrib);
     // get the first entry from the search result and free the result.
     $entry = ldap_first_entry($conn, $result);
     ldap_free_result($result);
     // now get the data from the entry and close the connection.
     $data = ldap_get_attributes($conn, $entry);
     ldap_close($conn);
     // go through the attribute data and add to the list. only
     // retain numeric keys; the ldap entry will have some
     // associative keys that are metadata and not useful to us here.
     $list = array();
     foreach ($attrib as $attr) {
         if (isset($data[$attr]) && is_array($data[$attr])) {
             foreach ($data[$attr] as $key => $val) {
                 if (is_int($key)) {
                     $list[] = $val;
                 }
             }
         }
     }
     // done!
     return $list;
 }
开发者ID:kalkin,项目名称:solarphp,代码行数:59,代码来源:Ldap.php

示例11: getfromDn

 public function getfromDn($dn, $noassoc = false)
 {
     $dn = $this->adescape($dn);
     $filter = "(&(objectCategory=group)(distinguishedname={$dn}))";
     $result = ldap_search($this->con, $this->dn, $filter, $this->attributes);
     if (ldap_errno($this->con)) {
         throw new searchException('Unable to conduct search: ' . ldap_error($this->con));
     }
     if (ldap_count_entries($this->con, $result) == 0) {
         $result = ldap_search($this->con2, $this->dn2, $filter, $this->attributes);
     }
     if (ldap_errno($this->con2)) {
         throw new searchException('Unable to conduct search: ' . ldap_error($this->con2));
     }
     return $this->parseResult($result, $noassoc);
 }
开发者ID:nephie,项目名称:AZL-website,代码行数:16,代码来源:adgroupModel.php

示例12: throwException

 /**
  *
  * @throws BadSearchFilterException
  * @throws NoSuchObjectException
  * @throws InvalidCredentialException
  * @throws AlreadyExistsException
  * @throws LdapException
  */
 public static function throwException(Connection $conn)
 {
     $error = ldap_error($conn->getResource());
     $code = ldap_errno($conn->getResource());
     switch ($code) {
         case -7:
             throw new BadSearchFilterException($error, $code);
         case 32:
             throw new NoSuchObjectException($error, $code);
         case 49:
             throw new InvalidCredentialException($error, $code);
         case 68:
             throw new AlreadyExistsException($error, $code);
     }
     throw new LdapException($error, $code);
 }
开发者ID:mangati,项目名称:php-ldap,代码行数:24,代码来源:ErrorHandler.php

示例13: connect

 /**
  * Connects to an LDAP server specified by $uri, with admin $user and $password.
  *
  * Returns a resource which can be used in LDAP functions like add, delete, search.
  *
  * @param string $uri Uri for LDAP, such as 'ldap://example.com'
  * @param string $format Format for an entry, like 'cn=%s,dc=example,dc=com'. %s is a literal placeholder for username
  * @param string $user Admin username
  * @param string $password Password for admin
  * @return resource
  */
 public static function connect($uri, $format, $user, $password)
 {
     if (!extension_loaded('ldap')) {
         die('LDAP extension is not loaded.');
     }
     $connection = ldap_connect($uri);
     if (!$connection) {
         throw new Exception("Could not connect to host '{$uri}'");
     }
     ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
     @ldap_bind($connection, sprintf($format, $user), $password);
     $err = ldap_errno($connection);
     switch ($err) {
         case 0x51:
             // LDAP_SERVER_DOWN
         // LDAP_SERVER_DOWN
         case 0x52:
             // LDAP_LOCAL_ERROR
         // LDAP_LOCAL_ERROR
         case 0x53:
             // LDAP_ENCODING_ERROR
         // LDAP_ENCODING_ERROR
         case 0x54:
             // LDAP_DECODING_ERROR
         // LDAP_DECODING_ERROR
         case 0x55:
             // LDAP_TIMEOUT
         // LDAP_TIMEOUT
         case 0x56:
             // LDAP_AUTH_UNKNOWN
         // LDAP_AUTH_UNKNOWN
         case 0x57:
             // LDAP_FILTER_ERROR
         // LDAP_FILTER_ERROR
         case 0x58:
             // LDAP_USER_CANCELLED
         // LDAP_USER_CANCELLED
         case 0x59:
             // LDAP_PARAM_ERROR
         // LDAP_PARAM_ERROR
         case 0x5a:
             // LDAP_NO_MEMORY
             throw new Exception("Could not connect to host '{$uri}'. (0x" . dechex($err) . ")");
             break;
     }
     return $connection;
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:58,代码来源:setup_accounts.php

示例14: init

 function init()
 {
     try {
         write_log('identiteam', 'Initialising');
         # Load default config, and merge with users' settings
         $this->load_config('config-default.inc.php');
         $this->load_config('config.inc.php');
         $this->app = rcmail::get_instance();
         $this->config = $this->app->config->get('identiteam');
         # Load LDAP & mail config at once
         $this->ldap = $this->config['ldap'];
         $this->mail = $this->config['mail'];
         $this->server = $this->ldap['server'];
         $this->referr = $this->ldap['referrals'];
         $this->b_user = $this->ldap['bind_user'];
         $this->b_pass = $this->ldap['bind_pass'];
         $this->filter = $this->ldap['filter'];
         $this->domain = $this->ldap['domain'];
         # Get these fields
         $this->fields = explode(',', $this->ldap['fields']);
         array_push($this->fields, $this->ldap['extraEmailField']);
         $this->conn = ldap_connect($this->server);
         if (is_resource($this->conn)) {
             ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
             ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $this->referr);
             $bound = ldap_bind($this->conn, $this->b_user, $this->b_pass);
             if ($bound) {
                 // Create signature
                 $this->add_hook('user2email', array($this, 'user2email'));
                 $this->initialised = true;
             } else {
                 $log = sprintf("Bind to server '%s' failed. Con: (%s), Error: (%s)", $this->server, $this->conn, ldap_errno($this->conn));
                 write_log('identiteam', $log);
             }
         } else {
             $log = sprintf("Connection to the server failed: (Error=%s)", ldap_errno($this->conn));
             write_log('identiteam', $log);
         }
     } catch (Exception $exc) {
         write_log('identiteam', 'Fail to initialise: ' . $exc->getMessage());
     }
     if ($this->initialised) {
         write_log('identiteam', 'Initialised');
     }
 }
开发者ID:zsmj513,项目名称:Roundcube-Plugins,代码行数:45,代码来源:identiteam.php

示例15: authenticate

 public function authenticate($ps_username, $ps_password = '', $pa_options = null)
 {
     $vo_bind = $this->bindToDirectory($ps_username, $ps_password);
     if (!$vo_bind) {
         if (ldap_get_option($this->getLinkIdentifier(), 0x32, $extended_error)) {
             $vs_bind_rdn = $this->getProcessedConfigValue("ldap_bind_rdn_format", $ps_username, "", "");
             caLogEvent("ERR", "LDAP ERROR (" . ldap_errno($this->getLinkIdentifier()) . ") {$extended_error} [{$vs_bind_rdn}]", "OpenLDAP::Authenticate");
         }
         return false;
     }
     // check group membership
     if (!$this->hasRequiredGroupMembership($ps_username)) {
         return false;
     }
     // user role and group membership syncing with directory
     $this->syncWithDirectory($ps_username);
     return true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:18,代码来源:AbstractLDAPAuthAdapter.php


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