cvs: peardoc /en/package networking.xml text.xml /en/package/networking net-ldap.xml /en/package/networking/net-ldap connect.xml query.xml
results.xml

From: Date: Mon, 09 Apr 2007 18:19:13 +0000
Subject: cvs: peardoc /en/package networking.xml text.xml /en/package/networking net-ldap.xml /en/package/networking/net-ldap connect.xml query.xml
results.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-9609@lists.php.net to get a copy of this message
cweiske Mon Apr 9 18:19:13 2007 UTC Added files: /peardoc/en/package/networking net-ldap.xml /peardoc/en/package/networking/net-ldap connect.xml query.xml results.xml Modified files: /peardoc/en/package networking.xml text.xml Log: Net_LDAP documentation

http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking.xml?r1=1.20&r2=1.21&diff_format=u Index: peardoc/en/package/networking.xml diff -u peardoc/en/package/networking.xml:1.20 peardoc/en/package/networking.xml:1.21 --- peardoc/en/package/networking.xml:1.20 Sat Dec 30 22:57:48 2006 +++ peardoc/en/package/networking.xml Mon Apr 9 18:19:13 2007 @@ -1,6 +1,6 @@ -<!-- $Revision: 1.20 $ --> +<!-- $Revision: 1.21 $ --> <chapter id="package.networking"> - + <title>Networking</title> <para> @@ -19,6 +19,7 @@ &package.networking.net-geoip; &package.networking.net-ipv4; &package.networking.net-ipv6; + &package.networking.net-ldap; &package.networking.net-mac; &package.networking.net-nntp; &package.networking.net-ping; http://cvs.php.net/viewvc.cgi/peardoc/en/package/text.xml?r1=1.11&r2=1.12&diff_format=u Index: peardoc/en/package/text.xml diff -u peardoc/en/package/text.xml:1.11 peardoc/en/package/text.xml:1.12 --- peardoc/en/package/text.xml:1.11 Thu Dec 7 12:15:25 2006 +++ peardoc/en/package/text.xml Mon Apr 9 18:19:13 2007 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <chapter id="package.text"> <title>Text</title> <titleabbrev>Text</titleabbrev> @@ -11,6 +11,7 @@ &package.text.text-captcha; &package.text.text-captcha-numeral; + &package.text.text-figlet; &package.text.text-highlighter; &package.text.text-languagedetect; &package.text.text-password; http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking/net-ldap.xml?view=markup&rev=1.1 Index: peardoc/en/package/networking/net-ldap.xml +++ peardoc/en/package/networking/net-ldap.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <sect1 id="package.networking.net-ldap"> <title>Net_LDAP</title> <para> Query LDAP (Lightweight Directory Access Protocol) servers. </para> &package.networking.net-ldap.connect; &package.networking.net-ldap.query; &package.networking.net-ldap.results; <!-- FIXME: write more sections --> </sect1> <!-- 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 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 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking/net-ldap/connect.xml?view=markup&rev=1.1 Index: peardoc/en/package/networking/net-ldap/connect.xml +++ peardoc/en/package/networking/net-ldap/connect.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <sect2 id="package.networking.net-ldap.connecting"> <title>Connecting to an LDAP server</title> <para> To connect to an LDAP server, you should use <classname>Net_LDAP</classname>'s static <function>connect</function> method. It takes one parameter, an array full of configuration options, and either returns a <classname>Net_LDAP</classname> object if connecting works, or a <classname>PEAR_Error</classname> object in case of a failure. </para> <para> The following table lists all configuration options. If the default value for an option fits your needs, you don't need add it to your configuration array. <table> <title>Possible configuration options</title> <tgroup cols="3"> <thead> <row> <entry>Name</entry> <entry>Description</entry> <entry>Default</entry> </row> </thead> <tbody> <row> <entry><literal>host</literal></entry> <entry>LDAP server name to connect to</entry> <entry><literal>localhost</literal></entry> </row> <row> <entry><literal>port</literal></entry> <entry>Port on the server</entry> <entry>389</entry> </row> <row> <entry><literal>version</literal></entry> <entry>LDAP version</entry> <entry><literal>3</literal></entry> </row> <row> <entry><literal>starttls</literal></entry> <entry>TLS is started after connecting</entry> <entry><literal>false</literal></entry> </row> <row> <entry><literal>binddn</literal></entry> <entry>The distinguished name to bind as (username)</entry> <entry>(none)</entry> </row> <row> <entry><literal>bindpw</literal></entry> <entry>Password for the <literal>binddn</literal></entry> <entry>(none)</entry> </row> <row> <entry><literal>basedn</literal></entry> <entry>LDAP base name (root directory)</entry> <entry>(none)</entry> </row> <row> <entry><literal>options</literal></entry> <entry>Array of additional ldap options as key-value pairs</entry> <entry><literal>array()</literal></entry> </row> <row> <entry><literal>filter</literal></entry> <entry>Default search filter</entry> <entry><literal>(objectClass=*)</literal></entry> </row> <row> <entry><literal>scope</literal></entry> <entry>Default search scope, see <function>search</function></entry> <entry><literal>sub</literal></entry> </row> </tbody> </tgroup> </table> </para> <example> <title>Connecting to an LDAP server</title> <programlisting role="php"><![CDATA[ require_once 'Net/LDAP.php'; $config = array ( 'binddn' => 'cn=admin,ou=users,dc=example,dc=org', 'bindpw' => 'password', 'basedn' => 'ou=addressbook,dc=example,dc=org', 'host' => 'ldap.example.org' ); $ldap = Net_LDAP::connect($config); if (PEAR::isError($ldap)) { die($ldap->getMessage() . "\n"); } ]]></programlisting> </example> </sect2> <!-- 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 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 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking/net-ldap/query.xml?view=markup&rev=1.1 Index: peardoc/en/package/networking/net-ldap/query.xml +++ peardoc/en/package/networking/net-ldap/query.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <sect2 id="package.networking.net-ldap.query"> <title>Querying a server</title> <para> After connecting to the server, you can use <classname>Net_LDAP</classname>'s <function>search</function> method to search the directory. The method takes three parameters: <itemizedlist> <listitem> <para> <literal>$base</literal> is the base search DN. If kept <literal>null</literal>, the default search DN configured when connecting is used. </para> </listitem> <listitem> <para> <literal>$filter</literal> is the query filter that determines which results are returned. </para> </listitem> <listitem> <para> <literal>$params</literal> is an array of configuration options for the current query. <table> <title>Possible configuration parameters</title> <tgroup cols="3"> <thead> <row> <entry>Name</entry> <entry>Description</entry> <entry>Default</entry> </row> </thead> <tbody> <row> <entry><literal>scope</literal></entry> <entry> The scope used for searching: <itemizedlist> <listitem> <para> <literal>base</literal> - Just one entry </para> </listitem> <listitem> <para> <literal>sub</literal> - The whole tree </para> </listitem> <listitem> <para> <literal>one</literal> - Immediately below <literal>$base</literal> </para> </listitem> </itemizedlist> </entry> <entry><literal>sub</literal></entry> </row> <row> <entry><literal>sizelimit</literal></entry> <entry>Number of entries returned at maximum</entry> <entry><literal>0</literal> (no limit)</entry> </row> <row> <entry><literal>timelimit</literal></entry> <entry>Seconds to spent for searching</entry> <entry><literal>0</literal> (no limit)</entry> </row> <row> <entry><literal>attrsonly</literal></entry> <entry>If <literal>true</literal>, only attribute names are returned</entry> <entry><literal>false</literal></entry> </row> <row> <entry><literal>attributes</literal></entry> <entry> Array of attribute names, which the entry should contain. It is good practice to limit this to just the ones you need. </entry> <entry><literal>array()</literal> (all attributes)</entry> </row> </tbody> </tgroup> </table> </para> </listitem> </itemizedlist> </para> <example> <title>Making a search query</title> <programlisting role="php"><![CDATA[ $filter = 'sn=Joe*'; $searchbase = 'ou=addressbook,dc=example,dc=org'; $options = array( 'scope' => 'sub', 'attributes' => array('sn') ); $result = $ldap->search($searchbase, $filter, $options); if (PEAR::isError($result)) { die($result->getMessage() . "\n"); } ]]></programlisting> </example> </sect2> <!-- 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 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 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking/net-ldap/results.xml?view=markup&rev=1.1 Index: peardoc/en/package/networking/net-ldap/results.xml +++ peardoc/en/package/networking/net-ldap/results.xml <?xml version="1.0" encoding="utf-8" ?> <!-- $Revision: 1.1 $ --> <sect2 id="package.networking.net-ldap.results"> <title>Reading results</title> <para> When using <function>search</function>, you either get a <classname>PEAR_Error</classname> or a <classname>Net_LDAP_Search</classname> object. The latter can be used to retrieve the single <classname>Net_LDAP_Entry</classname> objects that hold the attribute values. </para> <para> This can be done using the <function>entries</function> method that returns an array full of <classname>Net_LDAP_Entry</classname> objects. You could also use iterate while <function>shiftEntry</function> returns a valid entry object. <function>sorted</function> returns the entries sorted by the attributes set in the array passed as first parameter. </para> <para> A <classname>Net_LDAP_Entry</classname> should not just be <function>var_dump</function>ed - it has certain methods to access the attribute values: <function>getValues</function> returns an associative array of attribute name - value pairs, while <function>getValue</function> returns the value of the attribute passed as first parameter. </para> <example> <title>Iterating over a result set</title> <programlisting role="php"><![CDATA[ $entries = $result->entries(); foreach ($entries as $entry) { echo 'Name: ' . $entry->getValue('sn') . "\n"; } ]]></programlisting> </example> <example> <title>Iterating over a result set using while()</title> <programlisting role="php"><![CDATA[ while ($entry = $result->shiftEntry()) { echo 'Name: ' . $entry->getValue('sn') . "\n"; } ]]></programlisting> </example> </sect2>
« previous php.pear.doc (#9609) next »