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


PHP ldap_get_values_len函数代码示例

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


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

示例1: count

 /**
  * get the number of values
  *
  * @return the number of values
  */
 public final function count()
 {
     $arr = [];
     if ($this->get_node()->get_changed()) {
         $this->get_node()->refresh_entry();
     }
     $data = @ldap_get_values_len($this->get_ldapconn()->get_conn(), $this->get_node()->get_entry(), $this->get_name());
     return $data['count'];
 }
开发者ID:michaelvienna,项目名称:ldapclient,代码行数:14,代码来源:NodeAttribute.php

示例2: getObjectSid

 function getObjectSid($adConn, $dn, $distname)
 {
     //Select which attributes wa want
     $attrs = array("objectsid");
     //Filter creation
     $filter = "distinguishedname=" . addslashes($distname);
     //Do the seacrh!
     $search = ldap_search($adConn, $dn, $filter, $attrs) or die("**** happens, no connection!");
     $entry = ldap_first_entry($adConn, $search);
     $vals = ldap_get_values_len($adConn, $entry, "objectsid");
     return bin2hex($vals[0]);
 }
开发者ID:analogrithems,项目名称:idbroker,代码行数:12,代码来源:active_directory.php

示例3: readEntry

 /**
  * Read an LDAP entry.
  *
  * @param resource $ds
  *   LDAP connection resource.
  * @param resource $entryId
  *   LDAP entry resource.
  * @param string[] $binaryFields
  *   Names of binary attributes.
  *
  * @return array
  *   Attributes for an LDAP entry.
  */
 public static function readEntry($ds, $entryId, $binaryFields = array())
 {
     $data = array();
     for ($attribute = ldap_first_attribute($ds, $entryId, $attributeId); $attribute !== false; $attribute = ldap_next_attribute($ds, $entryId, $attributeId)) {
         $fieldValues = ldap_get_values($ds, $entryId, $attribute);
         if (in_array($attribute, $binaryFields)) {
             $fieldValues = ldap_get_values_len($ds, $entryId, $attribute);
         }
         if ($fieldValues['count'] == 1) {
             $data[$attribute] = $fieldValues[0];
         } else {
             for ($i = 0; $i < $fieldValues['count']; $i++) {
                 $data[$attribute][$i] = $fieldValues[$i];
             }
         }
     }
     return $data;
 }
开发者ID:grom358,项目名称:php-ldap,代码行数:31,代码来源:Utils.php

示例4: getUserLdapPhoto

 protected function getUserLdapPhoto($contactID)
 {
     $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
     $justthese = array("dn", 'jpegPhoto', 'givenName', 'sn');
     $this->getLdapCatalog()->ldapConnect(true);
     $ds = $this->getLdapCatalog()->ds;
     if ($ds) {
         $resource = @ldap_read($ds, $contactID, "phpgwaccounttype=u");
         $n_entries = @ldap_count_entries($ds, $resource);
         if ($n_entries == 1) {
             $first_entry = ldap_first_entry($ds, $resource);
             $obj = ldap_get_attributes($ds, $first_entry);
             if ($obj['jpegPhoto']) {
                 return ldap_get_values_len($ds, $first_entry, "jpegPhoto");
             }
         }
     }
     return false;
 }
开发者ID:cjvaz,项目名称:expressomail,代码行数:19,代码来源:CatalogAdapter.php

示例5: hydrateFromResult

 /**
  * I cannot imagine a lib being more crap than PHP LDAP one.
  * Structure information is melt with data, all functions need a 
  * connection handler, there are 367 ways of doing the things but only one 
  * works (at least with binary results) without failures nor error 
  * messages. Result keys change with automatic pagination without notice 
  * and so does values when they have accentuated characters. 
  * It has been a pain to write and a hell to debug, thanks to the 
  * obsolutely non informative documentation.
  *
  * hydrateFromResult
  *
  * Create an entity instance from a LDAP result.
  *
  * @param Resource $ldap_entry 
  * @return Entity
  */
 protected function hydrateFromResult($ldap_entry)
 {
     if ($ldap_entry === false) {
         return false;
     }
     $values = array();
     foreach ($this->getAttributes($ldap_entry) as $ldap_attribute) {
         $attribute = strpos($ldap_attribute, ';') === false ? $ldap_attribute : substr($ldap_attribute, 0, strpos($ldap_attribute, ';'));
         if ($this->map->getAttributeModifiers($attribute) & EntityMap::FIELD_BINARY) {
             $value = @ldap_get_values_len($this->handler, $ldap_entry, sprintf("%s", $ldap_attribute));
         } else {
             $value = @ldap_get_values($this->handler, $ldap_entry, $ldap_attribute);
         }
         if (is_array($value)) {
             if ($this->map->getAttributeModifiers($attribute) & EntityMap::FIELD_MULTIVALUED) {
                 unset($value['count']);
                 if (!$this->map->getAttributeModifiers($attribute) & EntityMap::FIELD_BINARY) {
                     $values[$attribute] = array_map(function ($val) {
                         if ($val === base64_encode(base64_decode($val, true))) {
                             return base64_decode($val);
                         }
                         return $val;
                     }, $value);
                 } else {
                     $values[$attribute] = $value;
                 }
             } else {
                 if ($value[0] === base64_encode(base64_decode($value[0], true))) {
                     $values[$attribute] = $value[0];
                 } else {
                     $values[$attribute] = $value[0];
                 }
             }
         }
     }
     $values['dn'] = ldap_get_dn($this->handler, $ldap_entry);
     return $this->map->createObject($values);
 }
开发者ID:chanmix51,项目名称:slapom,代码行数:55,代码来源:Collection.php

示例6: _getAccount

    /**
     * @param array $attrs An array of names of desired attributes
     * @return array An array of the attributes representing the account
     * @throws Zend_Ldap_Exception
     */
    private function _getAccount($acctname, $attrs = null)
    {
        $baseDn = $this->_getBaseDn();
        if (!$baseDn) {
            /**
             * @see Zend_Ldap_Exception
             */
            require_once 'Zend/Ldap/Exception.php';
            throw new Zend_Ldap_Exception(null, 'Base DN not set');
        }

        $accountFilter = $this->_getAccountFilter($acctname);
        if (!$accountFilter) {
            /**
             * @see Zend_Ldap_Exception
             */
            require_once 'Zend/Ldap/Exception.php';
            throw new Zend_Ldap_Exception(null, 'Invalid account filter');
        }

        if (!is_resource($this->_resource))
            $this->bind();

        $resource = $this->_resource;
        $str = $accountFilter;
        $code = 0;

        /**
         * @todo break out search operation into simple function (private for now)
         */

        if (!extension_loaded('ldap')) {
            /**
             * @see Zend_Ldap_Exception
             */
            require_once 'Zend/Ldap/Exception.php';
            throw new Zend_Ldap_Exception(null, 'LDAP extension not loaded');
        }

        $result = @ldap_search($resource,
                        $baseDn,
                        $accountFilter,
                        $attrs);
        if (is_resource($result) === true) {
            $count = @ldap_count_entries($resource, $result);
            if ($count == 1) {
                $entry = @ldap_first_entry($resource, $result);
                if ($entry) {
                    $acct = array('dn' => @ldap_get_dn($resource, $entry));
                    $name = @ldap_first_attribute($resource, $entry, $berptr);
                    while ($name) {
                        $data = @ldap_get_values_len($resource, $entry, $name);
                        $acct[$name] = $data;
                        $name = @ldap_next_attribute($resource, $entry, $berptr);
                    }
                    @ldap_free_result($result);
                    return $acct;
                }
            } else if ($count == 0) {
                /**
                 * @see Zend_Ldap_Exception
                 */
                require_once 'Zend/Ldap/Exception.php';
                $code = Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT;
            } else {

                /**
                 * @todo limit search to 1 record and remove some of this logic?
                 */

                $resource = null;
                $str = "$accountFilter: Unexpected result count: $count";
                /**
                 * @see Zend_Ldap_Exception
                 */
                require_once 'Zend/Ldap/Exception.php';
                $code = Zend_Ldap_Exception::LDAP_OPERATIONS_ERROR;
            }
            @ldap_free_result($result);
        }

        /**
         * @see Zend_Ldap_Exception
         */
        require_once 'Zend/Ldap/Exception.php';
        throw new Zend_Ldap_Exception($resource, $str, $code);
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:92,代码来源:Ldap.php

示例7: ldap_get_users_scalable

 /**
  * fill a database table with usernames from al LDAP directory
  * searching parameters are defined in configuration
  * DOES NOT SUPPORT PAGED RESULTS if more than a 1000 (AD)
  * @param string tablename
  * @param string columnname
  * @param string $extrafilter  if present returns only users having some values in some LDAP attribute
  * @return integer (nb of records added) or false in case of error
  */
 private function ldap_get_users_scalable($tablename, $columnname = 'username', $extrafilter = '')
 {
     global $CFG;
     execute_sql('TRUNCATE TABLE ' . $tablename);
     $ldapconnection = $this->ldap_connect();
     if (!$ldapconnection) {
         return false;
     }
     $filter = "(" . $this->config['user_attribute'] . "=*)";
     if (!empty($this->config['objectclass'])) {
         $filter .= "&(" . $this->config['objectclass'] . "))";
     }
     if ($extrafilter) {
         $filter = "(&{$filter}({$extrafilter}))";
     }
     // get all contexts and look for first matching user
     $ldap_contexts = explode(";", $this->config['contexts']);
     $ldapuserfields = $this->get_ldap_user_fields();
     $fieldstoimport = array_values($ldapuserfields);
     $fieldstoimport[] = $this->config['user_attribute'];
     // Lowercase all the fields to avoid case mismatch issues
     $ldapuserfields = array_map('strtolower', $ldapuserfields);
     log_info('retrieving these fields: ' . implode(',', $fieldstoimport) . "\n");
     $nbadded = 0;
     foreach ($ldap_contexts as $context) {
         $context = trim($context);
         if (empty($context)) {
             continue;
         }
         if ($this->config['search_sub'] == 'yes') {
             // use ldap_search to find first user from subtree
             $ldap_result = ldap_search($ldapconnection, $context, $filter, $fieldstoimport);
         } else {
             // search only in this context
             $ldap_result = ldap_list($ldapconnection, $context, $filter, $fieldstoimport);
         }
         if ($entry = ldap_first_entry($ldapconnection, $ldap_result)) {
             do {
                 $value = ldap_get_values_len($ldapconnection, $entry, $this->config['user_attribute']);
                 $value = $value[0];
                 // let's convert all keys to lowercase, to avoid case sensitivity issues
                 $ldaprec = array_change_key_case(ldap_get_attributes($ldapconnection, $entry));
                 $todb = new stdClass();
                 $todb->{$columnname} = $value;
                 foreach ($ldapuserfields as $dbfield => $ldapfield) {
                     if (array_key_exists($ldapfield, $ldaprec)) {
                         $todb->{$dbfield} = $ldaprec[$ldapfield][0];
                     } else {
                         log_warn("Ldap record contained no {$ldapfield} field to map to DB {$dbfield}");
                     }
                 }
                 insert_record($tablename, $todb, false, false);
                 $nbadded++;
                 if ($nbadded % 100 == 0) {
                     echo '.';
                 }
             } while ($entry = ldap_next_entry($ldapconnection, $entry));
             echo "\n";
         }
         ldap_free_result($ldap_result);
         // free mem
     }
     $this->ldap_close($ldapconnection);
     return $nbadded;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:74,代码来源:lib.php

示例8: getValuesLen

 /**
  * Get all binary values from the specified result entry.
  *
  * @param $entry
  * @param $attribute
  *
  * @return array
  */
 public function getValuesLen($entry, $attribute)
 {
     if ($this->suppressErrors) {
         return @ldap_get_values_len($this->getConnection(), $entry, $attribute);
     }
     return ldap_get_values_len($this->getConnection(), $entry, $attribute);
 }
开发者ID:HarkiratGhotra,项目名称:application,代码行数:15,代码来源:Ldap.php

示例9: getEntries

 /**
  * Wrapper for ldap_get_entries
  *
  * @access private
  * 
  */
 private function getEntries()
 {
     return $this->entries = @ldap_get_entries($this->ldap_handle, $this->result);
     // this way ldap_get_entries is binary safe
     $i = 0;
     $tmp_entries = array();
     $entry = ldap_first_entry($this->ldap_handle, $this->result);
     do {
         $attributes = @ldap_get_attributes($this->ldap_handle, $entry);
         for ($j = 0; $j < $attributes['count']; $j++) {
             $values = ldap_get_values_len($this->ldap_handle, $entry, $attributes[$j]);
             $tmp_entries[$i][strtolower($attributes[$j])] = $values;
         }
         $i++;
     } while ($entry = @ldap_next_entry($this->ldap_handle, $entry));
     if ($i) {
         $tmp_entries['count'] = $i;
     }
     $this->entries = $tmp_entries;
     return $this->entries;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:27,代码来源:class.ilLDAPResult.php

示例10: getObjectSid

 /**
  *  Recupere le SID de l'utilisateur
  *	Required by Active Directory
  *
  * 	@param	string		$ldapUser		Login de l'utilisateur
  * 	@return	string						Sid
  */
 function getObjectSid($ldapUser)
 {
     $criteria = '(' . $this->getUserIdentifier() . '=' . $ldapUser . ')';
     $justthese = array("objectsid");
     // if the directory is AD, then bind first with the search user first
     if ($this->serverType == "activedirectory") {
         $this->bindauth($this->searchUser, $this->searchPassword);
     }
     $i = 0;
     $searchDN = $this->people;
     while ($i <= 2) {
         $ldapSearchResult = @ldap_search($this->connection, $searchDN, $criteria, $justthese);
         if (!$ldapSearchResult) {
             $this->error = ldap_errno($this->connection) . " " . ldap_error($this->connection);
             return -1;
         }
         $entry = ldap_first_entry($this->connection, $ldapSearchResult);
         if (!$entry) {
             // Si pas de resultat on cherche dans le domaine
             $searchDN = $this->domain;
             $i++;
         } else {
             $i++;
             $i++;
         }
     }
     if ($entry) {
         $ldapBinary = ldap_get_values_len($this->connection, $entry, "objectsid");
         $SIDText = $this->binSIDtoText($ldapBinary[0]);
         return $SIDText;
     } else {
         $this->error = ldap_errno($this->connection) . " " . ldap_error($this->connection);
         return '?';
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:42,代码来源:ldap.class.php

示例11: ldap_get_entries

 /**
  * return entries from ldap
  *
  * Returns values like ldap_get_entries but is
  * binary compatible and return all attributes as array
  *
  * @return array ldap-entries
  */
 function ldap_get_entries($conn, $searchresult)
 {
     //Returns values like ldap_get_entries but is
     //binary compatible
     $i = 0;
     $fresult = array();
     $entry = ldap_first_entry($conn, $searchresult);
     do {
         $attributes = @ldap_get_attributes($conn, $entry);
         for ($j = 0; $j < $attributes['count']; $j++) {
             $values = ldap_get_values_len($conn, $entry, $attributes[$j]);
             if (is_array($values)) {
                 $fresult[$i][strtolower($attributes[$j])] = $values;
             } else {
                 $fresult[$i][strtolower($attributes[$j])] = array($values);
             }
         }
         $i++;
     } while ($entry = @ldap_next_entry($conn, $entry));
     //were done
     return $fresult;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:30,代码来源:auth.php

示例12: getValuesLen

 /**
  * {@inheritdoc}
  */
 public function getValuesLen($entry, $attribute)
 {
     return ldap_get_values_len($this->getConnection(), $entry, $attribute);
 }
开发者ID:adldap2,项目名称:adldap2,代码行数:7,代码来源:Ldap.php

示例13: __construct

 public function __construct($ldap, $entry, array $fieldMap)
 {
     $ldapEntry = ldap_get_attributes($ldap, $entry);
     $this->dn = ldap_get_dn($ldap, $entry);
     $this->fieldMap = $fieldMap;
     $this->attributes = array();
     for ($i = 0; $i < $ldapEntry['count']; $i++) {
         $attribute = $ldapEntry[$i];
         $attrib = strtolower($attribute);
         $count = $ldapEntry[$attribute]['count'];
         if ($attrib == $this->fieldMap['photodata']) {
             if ($data = @ldap_get_values_len($ldap, $entry, $attribute)) {
                 $this->attributes[$attrib] = $data;
                 // Get binary photo data
             }
         } else {
             $this->attributes[$attrib] = array();
             for ($j = 0; $j < $count; $j++) {
                 if (!in_array($ldapEntry[$attribute][$j], $this->attributes[$attrib])) {
                     $this->attributes[$attrib][] = str_replace('$', "\n", $ldapEntry[$attribute][$j]);
                 }
             }
         }
     }
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:25,代码来源:LDAPPeopleRetriever.php

示例14: QueryArray

 function QueryArray($str = '(ObjectClass=*)', $fields = false)
 {
     global $APPLICATION;
     if (strlen($this->arFields['BASE_DN']) <= 0) {
         return false;
     }
     $arBaseDNs = explode(";", $this->arFields['BASE_DN']);
     $info = false;
     $i = 0;
     if ($this->arFields["CONVERT_UTF8"] == "Y") {
         $str = $APPLICATION->ConvertCharset($str, SITE_CHARSET, "utf-8");
     }
     foreach ($arBaseDNs as $BaseDN) {
         global $APPLICATION;
         $BaseDN = trim($BaseDN);
         if ($BaseDN == "") {
             continue;
         }
         if ($this->arFields["CONVERT_UTF8"] == "Y") {
             $BaseDN = $APPLICATION->ConvertCharset($BaseDN, SITE_CHARSET, "utf-8");
         }
         $defaultMaxPageSizeAD = 1000;
         $pageSize = isset($this->arFields['MAX_PAGE_SIZE']) && intval($this->arFields['MAX_PAGE_SIZE'] > 0) ? intval($this->arFields['MAX_PAGE_SIZE']) : $defaultMaxPageSizeAD;
         $cookie = '';
         do {
             if (CLdapUtil::isLdapPaginationAviable()) {
                 ldap_control_paged_result($this->conn, $pageSize, false, $cookie);
             }
             if ($fields === false) {
                 $sr = @ldap_search($this->conn, $BaseDN, $str);
             } else {
                 $sr = @ldap_search($this->conn, $BaseDN, $str, $fields);
             }
             if ($sr) {
                 $entry = ldap_first_entry($this->conn, $sr);
                 if ($entry) {
                     if (!is_array($info)) {
                         $info = array();
                         $i = 0;
                     }
                     do {
                         $attributes = ldap_get_attributes($this->conn, $entry);
                         for ($j = 0; $j < $attributes['count']; $j++) {
                             $values = @ldap_get_values_len($this->conn, $entry, $attributes[$j]);
                             if ($values === false) {
                                 continue;
                             }
                             $bPhotoAttr = in_array($attributes[$j], self::$PHOTO_ATTRIBS);
                             $info[$i][strtolower($attributes[$j])] = $bPhotoAttr ? $values : $this->WorkAttr($values);
                         }
                         if (!is_set($info[$i], 'dn')) {
                             if ($this->arFields["CONVERT_UTF8"] == "Y") {
                                 $info[$i]['dn'] = $APPLICATION->ConvertCharset(ldap_get_dn($this->conn, $entry), "utf-8", SITE_CHARSET);
                             } else {
                                 $info[$i]['dn'] = ldap_get_dn($this->conn, $entry);
                             }
                         }
                         $i++;
                     } while ($entry = ldap_next_entry($this->conn, $entry));
                 }
             } elseif ($sr === false) {
                 $APPLICATION->ThrowException("LDAP_SEARCH_ERROR");
             }
             if (CLdapUtil::isLdapPaginationAviable()) {
                 ldap_control_paged_result_response($this->conn, $sr, $cookie);
             }
         } while ($cookie !== null && $cookie != '');
     }
     return $info;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:70,代码来源:ldap.php

示例15: ldap_get_entries

 /**
  * Return entries from ldap
  *
  * Returns values like ldap_get_entries but is binary compatible and return 
  * all attributes as array
  *
  * @return array ldap-entries
  */
 private function ldap_get_entries($conn, $searchresult)
 {
     $i = 0;
     $fresult = array();
     $entry = ldap_first_entry($conn, $searchresult);
     do {
         $attributes = @ldap_get_attributes($conn, $entry);
         for ($j = 0; $j < $attributes['count']; $j++) {
             $values = ldap_get_values_len($conn, $entry, $attributes[$j]);
             if (is_array($values)) {
                 $fresult[$i][$attributes[$j]] = $values;
             } else {
                 $fresult[$i][$attributes[$j]] = array($values);
             }
         }
         $i++;
     } while ($entry = @ldap_next_entry($conn, $entry));
     // We're done
     return $fresult;
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:28,代码来源:lib.php


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