php-doc-en/reference/ldap/functions/ldap-compare.xml
Jakub Vrana 2bed4f6ded Fix return types (2/2)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@189137 c90b9560-bf6c-de11-be94-00142212c4b1
2005-06-24 09:11:47 +00:00

105 lines
2.9 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ldap.xml, last change in rev 1.12 -->
<refentry id="function.ldap-compare">
<refnamediv>
<refname>ldap_compare</refname>
<refpurpose>Compare value of attribute found in entry specified with DN</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>mixed</type><methodname>ldap_compare</methodname>
<methodparam><type>resource</type><parameter>link_identifier</parameter></methodparam>
<methodparam><type>string</type><parameter>dn</parameter></methodparam>
<methodparam><type>string</type><parameter>attribute</parameter></methodparam>
<methodparam><type>string</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<simpara>
Returns &true; if <parameter>value</parameter> matches otherwise returns &false;. Returns -1 on error.
</simpara>
<para>
<function>ldap_compare</function> is used to compare <parameter>value</parameter>
of <parameter>attribute</parameter> to value of same attribute in LDAP directory
entry specified with <parameter>dn</parameter>.
</para>
<simpara>
The following example demonstrates how to check whether or not given password matches
the one defined in DN specified entry.
</simpara>
<example>
<title>Complete example of password check</title>
<programlisting role="php">
<![CDATA[
<?php
$ds=ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind
if (ldap_bind($ds)) {
// prepare data
$dn = "cn=Matti Meikku, ou=My Unit, o=My Company, c=FI";
$value = "secretpassword";
$attr = "password";
// compare value
$r=ldap_compare($ds, $dn, $attr, $value);
if ($r === -1) {
echo "Error: " . ldap_error($ds);
} elseif ($r === true) {
echo "Password correct.";
} elseif ($r === false) {
echo "Wrong guess! Password incorrect.";
}
} else {
echo "Unable to bind to LDAP server.";
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server.";
}
?>
]]>
</programlisting>
</example>
<warning>
<para>
<function>ldap_compare</function> can NOT be used to compare BINARY values!
</para>
</warning>
<note>
<para>
This function was added in 4.0.2.
</para>
</note>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->