function.ldap-get-values.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 154 行

HTML
154
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Get all values from a result entry</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-get-values-len.html">ldap_get_values_len</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ldap-list.html">ldap_list</a></div> <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.ldap-get-values" class="refentry"> <div class="refnamediv">  <h1 class="refname">ldap_get_values</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">ldap_get_values</span> &mdash; <span class="dc-title">Get all values from a result entry</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">array</span> <span class="methodname"><b><b>ldap_get_values</b></b></span>    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$link_identifier</tt></span>   , <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$result_entry_identifier</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$attribute</tt></span>   )</div>  <p class="para rdfs-comment">   Reads all the values of the attribute in the entry in the result.  </p>  <p class="para">   This call needs a <i><tt class="parameter">result_entry_identifier</tt></i>,   so needs to be preceded by one of the ldap search calls and one   of the calls to get an individual entry.  </p>  <p class="para">   You application will either be hard coded to look for certain   attributes (such as &quot;surname&quot; or &quot;mail&quot;) or you will have to use   the <a href="function.ldap-get-attributes.html" class="function">ldap_get_attributes()</a> call to work out   what attributes exist for a given entry.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">link_identifier</tt></i></span>     <dd>      <p class="para">       An LDAP link identifier, returned by <a href="function.ldap-connect.html" class="function">ldap_connect()</a>.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">result_entry_identifier</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">attribute</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns an array of values for the attribute on success and <b><tt>FALSE</tt></b> on   error. The number of values can be found by indexing &quot;count&quot; in the   resultant array. Individual values are accessed by integer index in the   array.  The first index is 0.  </p>  <p class="para">   LDAP allows more than one entry for an attribute, so it can, for example,   store a number of email addresses for one person&#039;s directory entry all   labeled with the attribute &quot;mail&quot;   <div class="informalexample">    <pre class="literallayout">    return_value[&quot;count&quot;] = number of values for attribute    return_value[0] = first value of attribute    return_value[i] = ith value of attribute    </pre>   </div>  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 List all values of the &quot;mail&quot; attribute for a     directory entry </b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;$ds&nbsp;is&nbsp;a&nbsp;valid&nbsp;link&nbsp;identifier&nbsp;for&nbsp;a&nbsp;directory&nbsp;server<br /><br />//&nbsp;$sr&nbsp;is&nbsp;a&nbsp;valid&nbsp;search&nbsp;result&nbsp;from&nbsp;a&nbsp;prior&nbsp;call&nbsp;to<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one&nbsp;of&nbsp;the&nbsp;ldap&nbsp;directory&nbsp;search&nbsp;calls<br /><br />//&nbsp;$entry&nbsp;is&nbsp;a&nbsp;valid&nbsp;entry&nbsp;identifier&nbsp;from&nbsp;a&nbsp;prior&nbsp;call&nbsp;to<br />//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one&nbsp;of&nbsp;the&nbsp;calls&nbsp;that&nbsp;returns&nbsp;a&nbsp;directory&nbsp;entry<br /><br /></span><span style="color: #0000BB">$values&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_get_values</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"mail"</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$values</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;email&nbsp;addresses&nbsp;for&nbsp;this&nbsp;entry.&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br /><br />for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$values</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">];&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$values</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.ldap-get-values-len.html" class="function" rel="rdfs-seeAlso">ldap_get_values_len()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-get-values-len.html">ldap_get_values_len</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ldap-list.html">ldap_list</a></div> <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?