php-doc-en/reference/ldap/functions/ldap-compare.xml
Daniel Egeberg 96c9d88bad Converted to utf-8
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
2010-03-28 22:10:10 +00:00

155 lines
3.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.ldap-compare" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ldap_compare</refname>
<refpurpose>Compare value of attribute found in entry specified with DN</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<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>
<para>
Compare <parameter>value</parameter> of <parameter>attribute</parameter>
with value of same attribute in an LDAP directory entry.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>link_identifier</parameter></term>
<listitem>
<para>
An LDAP link identifier, returned by <function>ldap_connect</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>dn</parameter></term>
<listitem>
<para>
The distinguished name of an LDAP entity.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>attribute</parameter></term>
<listitem>
<para>
The attribute name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The compared value.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if <parameter>value</parameter> matches otherwise returns
&false;. Returns -1 on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
The following example demonstrates how to check whether or not given password matches
the one defined in DN specified entry.
</para>
<para>
<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>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<warning>
<para>
<function>ldap_compare</function> can NOT be used to compare BINARY values!
</para>
</warning>
</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:"~/.phpdoc/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
-->