uTools-Manuals/docs/php/ldap_errno.html
2019-04-08 23:22:26 +08:00

93 lines
6.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Return the LDAP error number of the last LDAP command</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.ldap-errno" class="refentry">
<div class="refnamediv">
<h1 class="refname">ldap_errno</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ldap_errno</span> &mdash; <span class="dc-title">Return the LDAP error number of the last LDAP command</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.ldap-errno-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>ldap_errno</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
) : <span class="type">int</span></div>
<p class="para rdfs-comment">
Returns the standardized error number returned by the last LDAP command.
This number can be converted into a textual error message using
<span class="function"><a href="ldap_err2str.html" class="function">ldap_err2str()</a></span>.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.ldap-errno-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">link_identifier</code></dt>
<dd>
<p class="para">
An LDAP link identifier, returned by <span class="function"><a href="ldap_connect.html" class="function">ldap_connect()</a></span>.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.ldap-errno-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Return the LDAP error number of the last LDAP command for this
link.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.ldap-errno-examples">
<h3 class="title">范例</h3>
<p class="para">
Unless you lower your warning level in your <var class="filename">php.ini</var> sufficiently or
prefix your LDAP commands with @ (at) characters to suppress warning
output, the errors generated will also show up in your HTML output.
<div class="example" id="example-5395">
<p><strong>Example #1 Generating and catching an error</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;example&nbsp;contains&nbsp;an&nbsp;error,&nbsp;which&nbsp;we&nbsp;will&nbsp;catch.<br /></span><span style="color: #0000BB">$ld&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$bind&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;syntax&nbsp;error&nbsp;in&nbsp;filter&nbsp;expression&nbsp;(errno&nbsp;87),<br />//&nbsp;must&nbsp;be&nbsp;"objectclass=*"&nbsp;to&nbsp;work.<br /></span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;&nbsp;@</span><span style="color: #0000BB">ldap_search</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"o=Myorg,&nbsp;c=DE"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"objectclass"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$res</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"LDAP-Errno:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">ldap_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"LDAP-Error:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">ldap_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Argh!&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_get_entries</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;matching&nbsp;entries.&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.ldap-errno-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="ldap_err2str.html" class="function" rel="rdfs-seeAlso">ldap_err2str()</a> - Convert LDAP error number into string error message</span></li>
<li class="member"><span class="function"><a href="ldap_error.html" class="function" rel="rdfs-seeAlso">ldap_error()</a> - Return the LDAP error message of the last LDAP command</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>