svn: /pear/peardoc/trunk/en/package/networking/net-ldap2/ attributes.xml errorhandling.xml ldif.xml
[email protected] (Benedikt Hallinger) Tue, 23 Mar 2010 07:37:50 +0000
| Newsgroups | php.pear.doc |
|---|---|
| Message-ID | <[email protected]> |
beni Tue, 23 Mar 2010 07:37:50 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=296658
Log:
* Updated docs for schema stuff
* corrected some spelling errors
Changed paths:
U pear/peardoc/trunk/en/package/networking/net-ldap2/attributes.xml
U pear/peardoc/trunk/en/package/networking/net-ldap2/errorhandling.xml
U pear/peardoc/trunk/en/package/networking/net-ldap2/ldif.xml
Modified: pear/peardoc/trunk/en/package/networking/net-ldap2/attributes.xml
===================================================================
--- pear/peardoc/trunk/en/package/networking/net-ldap2/attributes.xml 2010-03-23 03:36:04 UTC (rev 296657)
+++ pear/peardoc/trunk/en/package/networking/net-ldap2/attributes.xml 2010-03-23 07:37:50 UTC (rev 296658)
@@ -30,6 +30,7 @@
</para>
</listitem>
</itemizedlist>
+ Also note that if you try to fetch an attribute, that is not set at the entry, an empty string will be returned.
</para>
<example><info><title>Reading attributes</title></info>
@@ -232,4 +233,54 @@
]]></programlisting>
</example>
</refsection>
-</refentry>
+
+ <refsection>
+ <title>Schema checks</title>
+ <para>
+ When operating on an LDAP connection, you might want to retrieve informations
+ regarding the directory servers schema. Often this is the case to verify that
+ your program only querys attributes that are valid for an entry or to ensure
+ that you only try to write such attributes to the server.
+ </para>
+ <para>
+ To get that inforamtion, you can use the <classname>Net_LDAP2_Schema</classname> which is
+ retrieved via the <classname>Net_LDAP2</classname> object. It allows you to perform
+ various querys, not only on attributes and object classes, but also on DIT
+ content rules, for example. For often needed functionality, shorthand
+ methods are implemented since version 2.0.10 like <function>attributeExists</function>,
+ <function>objectClassExists</function>, <function>getAssignedOCLs</function>
+ and <function>checkAttribute</function>.
+ </para>
+ <example>
+ <title>Performing basic schema checks</title>
+ <programlisting role="php"><![CDATA[
+// Fetch the schema object for the connected directory server.
+$schema = $ldap->schema();
+
+// this may have failed since not every server allows us
+// to fetch the schema without permission. Also technical
+// problems may prevent us from this.
+if ( Net_LDAP2::isError($schema) ) {
+ die('SCHEMA ERROR: '.$schema->getMessage()."\n");
+}
+
+// lets see, if an attribute is defined in the schema:
+if ( $schema->attributeExists('myCoolAttribute') ) {
+ echo "Attribute 'myCoolAttribute' is defined in the schema!";
+}
+
+// lets see, if an object class is defined in the schema:
+if ( $schema->attributeExists('myCoolOCL') ) {
+ echo "Object class 'myCoolOCL' is defined in the schema!";
+}
+
+// Check, if the attribute is defined in objectClasses.
+// This is especially useful if you want to know if
+// attributes are valid for a given set of object classes.
+if ( $schema->checkAttribute('myCoolAttribute', array('person', 'myCoolOCL')) ) {
+ echo "Attribute 'myCoolAttribute' is defined for the given OCLs!";
+}
+]]></programlisting>
+ </example>
+ </refsection>
+</refentry>
\ No newline at end of file
Modified: pear/peardoc/trunk/en/package/networking/net-ldap2/errorhandling.xml
===================================================================
--- pear/peardoc/trunk/en/package/networking/net-ldap2/errorhandling.xml 2010-03-23 03:36:04 UTC (rev 296657)
+++ pear/peardoc/trunk/en/package/networking/net-ldap2/errorhandling.xml 2010-03-23 07:37:50 UTC (rev 296658)
@@ -34,7 +34,7 @@
// Check, if an error occured and do something.
// Here we use die() to show the message of the error.
-if (PEAR::isError($result)) {
+if (Net_LDAP2::isError($result)) {
die($result->getMessage());
}
]]></programlisting>
Modified: pear/peardoc/trunk/en/package/networking/net-ldap2/ldif.xml
===================================================================
--- pear/peardoc/trunk/en/package/networking/net-ldap2/ldif.xml 2010-03-23 03:36:04 UTC (rev 296657)
+++ pear/peardoc/trunk/en/package/networking/net-ldap2/ldif.xml 2010-03-23 07:37:50 UTC (rev 296658)
@@ -14,10 +14,10 @@
<para>
LDIF files are in detail described at <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.ietf.org/rfc/rfc2849.txt">RFC 2849</link>.
- Shortly, they contain directory data in an plain text, human readable kind, much like
- a SQL file does. However, unlike SQL files LDIF files are mostly data based, not action based.
- There are two different LDIF file contents, which can be mixed freely - content and change files.
- The first and most often used one is the LDIF content file:
+ Shortly, they contain directory data in an plain text, human readable format, much like
+ a SQL file does. However, unlike an SQL dump, LDIF files are mostly data based, not action based.
+ There are two different possible LDIF file contents which can be mixed freely: content and change format.
+ The first and most often used one is the LDIF content format:
</para>
<example><info><title>Example LDIF content file</title></info>
@@ -159,7 +159,7 @@
<row>
<entry><literal>version</literal></entry>
<entry>Set the LDIF version to write to the resulting LDIF file.
- According to RFC 2849 currently the only legal value for this option is 1 currently.</entry>
+ According to RFC 2849 currently the only legal value for this option is 1.</entry>
<entry><literal>1</literal></entry>
</row>
<row>