Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: ldap_get_values - Manual
[go: Go Back, main page]

PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<ldap_get_values_lenldap_list" width="11" height="7"/>
view the version of this page
Last updated: Sun, 07 May 2006

ldap_get_values

(PHP 3, PHP 4, PHP 5)

ldap_get_values -- 結果エントリから全ての値を得る

説明

array ldap_get_values ( resource link_identifier, resource result_entry_identifier, string attribute )

成功した場合、指定した属性に関する値を配列を返します。エラーの場合 には、FALSE を返します。

ldap_get_values() 関数は、結果のエントリにおける 属性の全ての値を読み込むために使用されます。 エントリは、result_entry_identifier により指定されます。結果を有する配列において "count" と インデックス指定することにより値の数を得ることができます。 個々の値は、配列において整数インデックスを指定することによりアクセス できます。最初のインデックスは、0 です。

この関数のコールは、result_entry_identifier を必要とします。このため、事前に LDAP の検索用関数のコールと個々の エントリ取得用関数のコールを行っておく必要があります。

アプリケーションでは、("surname" または "mail" のような)特定の属性 を探すためにその属性をコードに埋め込んで置くか、さもなくば、指定した エントリに関して存在する属性を調べるために ldap_get_attributes() をコールする必要があります。

LDAP ではある属性に関して複数のエントリを持つことが可能です。 このため、例えば、ある人に関する "mail" という属性で呼ばれる全ての ディレクトリエントリについて多数の電子メールアドレスを保存することが できます。


return_value["count"] = 属性の値の数
return_value[0] = 属性の最初の値
return_value[i] = 属性の i 番目の値
      

例 1. あるディレクトリエントリの全ての "mail" 属性の一覧を表示します

<?php
// $ds はディレクトリサーバーの有効なリンク ID
// $sr は事前の LDAP 検索コールのどれかから返された有効な検索結果
// $entry はディレクトリエントリを返すコールのどれかから返された有効な
// エントリ ID

$values = ldap_get_values($ds, $entry, "mail");

echo
$values["count"] . " email addresses for this entry.<br />";

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



add a note add a note User Contributed Notes
ldap_get_values
viper_sb at IGETTOMUCHSPAMhotmail dot com
25-Mar-2003 11:24
Well this took me a while to find the problem, so I'm posting in case someone else runs in to this.

$sr = ldap_search($ds, "cn=me", "(objectclass=*)");
$entry = ldap_first_entry($ds, $sr);
do {
  // do other stuff
  $sr = "something else now";
  $values = ldap_get_values($ds, $entry, "attirib1");
  // do other stuff
} while ($entry = ldap_next_entry($ds, $entry));

If you change the search resource $sr to something else even though it's not used again it will kill the page it'll be a blank page and if you view the code you'll get different things depending on something no idea what.

This kepted happening I had forgotten I had used $sr so I was using it again and it would just not show the page whenever I used ldap_get_values, if this is a feature it would be nice to know. I haven't seen it happen with other functions.
software at inebria dot com
22-Jun-2001 02:34
It wasn't immediately obvious to me that the ldap_get_values function does not work with binary data - only strings.  If you fetch binary data with ldap_get_values you don't get a warning - just some trash.  For binary data you have to use ldap_get_values_len.

<ldap_get_values_lenldap_list" width="11" height="7"/>
 Last updated: Sun, 07 May 2006
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2006 The PHP Group
All rights reserved.
This mirror generously provided by: PacketBusiness, Inc.
Last updated: Sun Sep 3 15:22:48 2006 JST