PHP.mk документација

ldap_get_attributes

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.ldap-get-attributes.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.ldap-get-attributes.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
ldap_get_attributes

Референца за `function.ldap-get-attributes.php` со подобрена типографија и навигација.

function.ldap-get-attributes.php

ldap_get_attributes

(PHP 4, PHP 5, PHP 7, PHP 8)

ldap_get_attributesДобијте атрибути од запис од резултат од пребарување

= NULL

ldap_get_attributes(LDAP\Connection $ldap, LDAP\ResultEntry $entry): array

Чита атрибути и вредности од запис во резултатот од пребарувањето.

Откако ќе лоцирате специфичен запис во директориумот, можете да дознаете какви информации се чуваат за тој запис со користење на овој повик. Овој повик би го користеле за апликација која „прелистува“ записи во директориумот и/или каде што не ја знаете структурата на записите во директориумот. Во многу апликации ќе пребарувате за специфичен атрибут како што е адреса на е-пошта или презиме, и нема да ве интересираат другите податоци што се чуваат.

return_value["count"] = number of attributes in the entry
return_value[0] = first attribute
return_value[n] = nth attribute

return_value["attribute"]["count"] = number of values for attribute
return_value["attribute"][0] = first value of the attribute
return_value["attribute"][i] = (i+1)th value of the attribute

Параметри

ldap

Еден LDAP\Connection инстанца, вратена од ldap_connect().

entry

Еден LDAP\ResultEntry instance.

Вратени вредности

Враќа целосни информации за записот во повеќедимензионален список.

Дневник на промени

Верзија = NULL
8.1.0 На ldap параметарот очекува LDAP\Connection инстанца сега; претходно, валидна ldap link resource се очекуваше.
8.1.0 На entry параметарот очекува LDAP\ResultEntry инстанца сега; претходно, валидна ldap result entry resource се очекуваше.

Примери

Пример #1 Покажете го списокот со атрибути што се чуваат за одреден запис во директориумот

<?php
// $ds is a valid LDAP\Connection instance for a directory server

// $sr is a valid search result from a prior call to
// one of the ldap directory search calls

$entry = ldap_first_entry($ds, $sr);

$attrs = ldap_get_attributes($ds, $entry);

echo
$attrs["count"] . " attributes held for this entry:<p>";

for (
$i=0; $i < $attrs["count"]; $i++) {
echo
$attrs[$i] . "<br />";
}
?>

Види Исто така

Белешки од корисници 6 белешки

kop на meme точка com
пред 22 години
It's good practice to use array_change_key_case() on the result of ldap_get_attributes() so your program can ignore case in attribute names just like ldap itself does.  (You wouldn't want ldap_get_attributes to _always_ flatten the case because you need a way to get the attribute names in a pretty format for display to the user.)
allie на pajunas точка com
пред 23 години
The array created by this function is similar to the on from ldap_get_entries() but when it creates array keys it alters the attribute's case inconsistently.  

ldap_get_entries() lowercases all of the attributes before keying the array with them, but this function appears to leave things as they are.

If you're having problems, do a print_r and make sure you're using correct case for array keys.  For example, you might need to use "objectClass" and not "objectclass".
software na inebria dot com
figroc at gmail dot com
As of PHP 4.0.5, the ldap_get_attributes function does not work with binary data.  If you're fetching a JPEG from an LDAP server, use ldap_get_values_len instead.
php точка net на hiddemann точка org
21 години пред
Note that ldap_get_attributes fetches attributes AND values from the LDAP server. Depending on the data stored in the entry, the following code might work a dozen times faster (or even better, but faster in general) than the code in Example 1:

<?php
// $ds is the link identifier for the directory

// $sr is a valid search result from a prior call to
// one of the ldap directory search calls

$entry = ldap_first_entry($ds, $sr);

$attrs = array();
$attribute = ldap_first_attribute($ds,$entry,$identifier);
while ($attribute) {
   $attrs[] = $attribute;
   $attribute=ldap_next_attribute($ds,$entry,$identifier);
}

echo count($attrs) . " attributes held for this entry:<p>";

for ($i=0; $i<count($attrs); $i++) {
   echo $attrs[$i] . "<br />";
}
?>

You may want to check the time difference with the function "microtime".
Снешко Снежак
19 години пред
Code and function to extract all attributes from all entryes in a certain DN. Maybe not the most timewise efficient but it works.

$entry = ldap_first_entry($ds, $sr);
write_attr($entry,$ds);
for ($i = 0; $i < $n_entries; $i++){
   $entry = ldap_next_entry($ds, $entry);
   write_attr($entry,$ds);
}

function write_attr($entry,$ds){
   $attrs = ldap_get_attributes ($ds, $entry);
   for ($j = 0; $j < $attrs["count"]; $j++){
      $attr_name = $attrs[$j];
      $attrs["$attr_name"]["count"] . "\n";
      for ($k = 0; $k < $attrs["$attr_name"]["count"]; $k++) {
             echo ">>>>>>";
             echo $attr_name.": ".$attrs["$attr_name"][$k]."\n";
      }
   }
}
dunc на rumbletum точка org
пред 18 години
I spent quite a while scratching my head about how to read operational attributes such as create and modify timestamps.

This function solved it....

function get_entry_system_attrs( $ds, $dn, $deref=LDAP_DEREF_NEVER )
{
   $conn = $ds;
   $attrs = array( 'creatorsname', 'createtimestamp', 'modifiersname',
         'structuralObjectClass', 'entryUUID',  'modifytimestamp',
         'subschemaSubentry', 'hasSubordinates', '+' );
   $search = @ldap_read( $conn, $dn, '(objectClass=*)', $attrs, 0, 0, 0, $deref );
   if( ! $search )
      return false;
   $entry = ldap_first_entry( $conn, $search );
   if( ! $entry)
       return false;
   $attrs = ldap_get_attributes( $conn, $entry );
   if( ! $attrs )
      return false;
   if( ! isset( $attrs['count'] ) )
      return false;
   $count = $attrs['count'];
   unset( $attrs['count'] );
   $return_attrs = array();
   for( $i=0; $i<$count; $i++ ) {
      $attr_name = $attrs[$i];
      unset( $attrs[$attr_name]['count'] );
      $return_attrs[$attr_name] = $attrs[$attr_name];
   }
   return $return_attrs;
}
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.