mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 14:28:56 +00:00
189 lines
4.6 KiB
XML
189 lines
4.6 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 class="union"><type>bool</type><type>int</type></type><methodname>ldap_compare</methodname>
|
|
<methodparam><type>LDAP\Connection</type><parameter>ldap</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>
|
|
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>controls</parameter><initializer>&null;</initializer></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>ldap</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
&ldap.parameter.ldap;
|
|
</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>
|
|
<varlistentry>
|
|
<term><parameter>controls</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Array of <link linkend="ldap.controls">LDAP Controls</link> to send with the request.
|
|
</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="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&ldap.changelog.ldap-object;
|
|
&ldap.changelog.controls-nullable;
|
|
<row>
|
|
<entry>7.3</entry>
|
|
<entry>
|
|
Support for <parameter>controls</parameter> added
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</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
|
|
-->
|