[prev in list] [next in list] [prev in thread] [next in thread]
List: pear-doc
Subject: [PEAR-DOC] cvs: peardoc /en/package/networking/net-ldap attributes.xml
From: "Benedikt Hallinger" <beni () php ! net>
Date: 2008-10-16 10:48:45
Message-ID: cvsbeni1224154125 () cvsserver
[Download RAW message or body]
beni Thu Oct 16 10:48:45 2008 UTC
Modified files:
/peardoc/en/package/networking/net-ldap attributes.xml
Log:
* Documentet complex updates of objectclasses
http://cvs.php.net/viewvc.cgi/peardoc/en/package/networking/net-ldap/attributes.xml?r1=1.6&r2=1.7&diff_format=u
Index: peardoc/en/package/networking/net-ldap/attributes.xml
diff -u peardoc/en/package/networking/net-ldap/attributes.xml:1.6 \
peardoc/en/package/networking/net-ldap/attributes.xml:1.7
--- peardoc/en/package/networking/net-ldap/attributes.xml:1.6 Thu Oct 9 15:16:43 \
2008
+++ peardoc/en/package/networking/net-ldap/attributes.xml Thu Oct 16 10:48:45 2008
@@ -6,8 +6,6 @@
</refnamediv>
<refsection><info><title>Reading attributes</title></info>
-
-
<para>
Reading attribute values depends on the selection of those attributes at \
search time. You can only access attributes that where selected! You can read \
attribute values using either <classname>Net_LDAP_Entry</classname>'s \
<function>getValues</function> or <function>getValue</function> method. @@ -34,7 \
+32,7 @@ </itemizedlist>
</para>
<example><info><title>Reading attributes</title></info>
-
+
<programlisting role="php"><![CDATA[
// read Surename, singlevalued
$surename = $entry->getValue('sn', 'single');
@@ -48,7 +46,7 @@
<para>
If you want to read the distinguished name of an Entry (DN), you must use a \
different method: <function>dn</function> <example><info><title>Reading an entries \
DN</title></info>
-
+
<programlisting role="php"><![CDATA[
$dn = $entry->dn();
]]></programlisting>
@@ -58,10 +56,8 @@
</refsection>
<refsection><info><title>Regular expressions on attributes</title></info>
-
-
<para>
- PEAR::Net_LDAP features the unique feature to apply a regular expression \
match directly against attributes, so + PEAR::Net_LDAP has the unique \
feature to apply a regular expression match directly against \
attributes, so
you do not need to manually fetch all values and run the regex against \
them.
Instead, you can use <classname>Net_LDAP_Entry</classname>'s \
<function>preg_match</function> function.
The behavior of this function is the same as PHPs preg_match(), but the \
$matches array is slightly different. @@ -70,7 +66,7 @@
<function>preg_match</function> returns true or false, depending on match.
</para>
<example><info><title>Performing preg_match on attribute \
values</title></info>
-
+
<programlisting role="php"><![CDATA[
// Look, if the user has an emailadress for 'example', if so,
// we want to display the tld:
@@ -88,8 +84,6 @@
</refsection>
<refsection><info><title>General information regarding attribute \
changing</title></info>
-
-
<para>
It is important to know how attribute changing works. Modifications to \
an entry
through the <classname>Net_LDAP_Entry</classname>-object are local only.
@@ -109,8 +103,6 @@
</refsection>
<refsection><info><title>Adding attributes</title></info>
-
-
<para>
Adding attrbiute values to an entry is an easy task. You just need to call \
<function>add</function>!
The parameter is an array whose keys are the attribute names and values \
the attributes values. @@ -118,7 +110,7 @@
If the attribute doesn't exist so far, it will be added, if it exists, the \
attributes values will be added. </para>
<example><info><title>Adding attributes</title></info>
-
+
<programlisting role="php"><![CDATA[
// Adding several attributes:
$result = $entry->add(
@@ -134,8 +126,6 @@
</refsection>
<refsection><info><title>Changing attributes</title></info>
-
-
<para>
Changing values is with the <function>replace</function> method as easy \
as adding values. However, you have to be a little more careful.
The expected parameter is an array describing the new absolute state of \
the named @@ -145,7 +135,7 @@
The keys of the array are expected to be the attributes names.
</para>
<example><info><title>Changing attributes</title></info>
-
+
<programlisting role="php"><![CDATA[
// Changing several attributes:
// 'sn' is changed to "Smith", 'gn' gets deleted and mail will
@@ -163,8 +153,6 @@
</refsection>
<refsection><info><title>Deleting attributes</title></info>
-
-
<para>
Using the <function>delete</function> method you are able to delete \
specific attributes values as well as delete a whole attribute.
@@ -176,7 +164,7 @@
in the same function call.
</para>
<example><info><title>Deleting attributes</title></info>
-
+
<programlisting role="php"><![CDATA[
// Delete the whole entry:
$result = $entry->delete();
@@ -194,6 +182,54 @@
$result = $entry->delete( array('mail' => array('smith@example.org', \
'smith@example.de')) ); ]]></programlisting>
</example>
+ </refsection>
+ <refsection>
+ <title>Changing Objectclasses</title>
+ <para>
+ Object classes describe the attribute set of an entry with this \
objectclass set. + The entry stores the objectclass in a special attribute \
named "objectClass", + and of course you may alter that attribute like any \
other attribute. + </para>
+ <para>
+ However, special care must be taken if changing this attribute since
+ most directory servers impose rules on the other attributes the object \
class define. + For example, it is usually not possible to delete an \
objectclass if some of the attributes + the class describes are still in \
use by the entry. + This should be not much of a problem with optional \
attributes, but + sometimes objectclasses have mandatory attributes set. \
Also structural objectclasses + can only be added when creating new \
entrys. Because of the internal + architecture of Net_LDAP it is currently \
not possible to resolve those cases. + </para>
+ <para>
+ To add or remove objectclasses with mandatory attributes or new \
structural object classes, + you need to delete the old entry from the \
directory server and add the new one with the + new objectclass and \
attributes as fresh entry. + </para>
+ <example>
+ <title>Changing complex objectclasses</title>
+ <programlisting role="php"><![CDATA[
+// Let's assume that the objectclass myClass enforce the attribute "fooattr"
+// Take care that you have all attributes requested, otherwise the new
+// entry will not have all attributes set!
+$entry->add(array(
+ 'objectClass' => 'myClass',
+ 'fooatrr' => 'foo',
+ 'someotherattr' => array('bar', 'baz')
+ ));
+
+// Calling $entry->update() now will not succeed under some circumstances!
+// We construct a fresh entry object which is in fact a copy of the already
+// existing entry with all changes already applied (the local copy).
+// It is important, that at fetching time of $entry all attributes where selected!
+// Only the selected attributes will get copied.
+$changed_entry = Net_LDAP2_Entry::createFresh($entry->dn(), $entry->getValues());
+
+// Now delete the old entry and add the new one:
+$ldap->delete($entry);
+$ldap->add($changed_entry);
+
+]]></programlisting>
+ </example>
</refsection>
</refentry>
--
PEAR Documentation List Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic