PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_LDAP » Bug #4275

Problem with stepwise updates and Schema

Details

Submitted2005-05-03 22:09 UTC
Frommarian at kisd dot de
Assigneddelatbabel
StatusNo Feedback
PackageNet_LDAP
PHP Version4.3.11
Roadmaps(Not assigned)

Comments

[2005-05-03 22:09 UTC] marian at kisd dot de

Description:
------------
Hi Tarjei and Jan,

i am just testing Net_LDAP 0.6.6. I know it's not stable, but I would like to know if the following is a known problem.

My scenario:

I have an LDAP entry of objectclasss 'posixAccount'. Now I want to also make it a Samba account, so I add the required attributes to the entry and also add objectclass 'sambaSamAccount'.

When I finally call the update() method, I get an object class violation.

(Warning: ldap_modify(): Modify: Object class violation in c:\php\PEAR\pear\Net\LDAP\Entry.php on line 516)

This seems to be due to the fact that Entry::update() seems to run the changes in several steps. In order to work fine with schema checking, that should happen in only one step.

Please let me know whether this is a known issue, what the status is and also if you need help on this.

Thanks!

Marian

[2005-11-29 09:23 UTC] matthijs at cacholong dot nl

Here is a patch that fixes this problem in LDAP/Entry.php (version 0.6.6)

$ svn diff -r14:17 Entry.php
Index: Entry.php
===================================================================
--- Entry.php (revision 14)
+++ Entry.php (revision 17)
@@ -485,38 +485,21 @@
} else {
$this->_error['first'] = $this->_modAttrs;
$this->_error['count'] = count($this->_modAttrs);
-
- // modified attributes
- if (( count($this->_modAttrs)>0) &&
- !ldap_modify($this->_link, $this->dn(), $this->_modAttrs))
- {
- return $this->raiseError("Entry " . $this->dn() . " not modified(attribs not modified): " .
- ldap_error($this->_link),ldap_errno($this->_link));
+
+ foreach ( $this->_delAttrs as $k => $v ) {
+ if ( $v == '' && $this->exists($k) ) {
+ $this->_delAttrs[$k] = array();
+ }
}
-
- // attributes to be deleted
- if (( count($this->_delAttrs) > 0 ))
+
+ // Concatanate _modAttrs, _delAttrs and _addAttrs so that they are
+ // modified at once. (schemacheck requires that)
+ $_attrs = $this->_modAttrs + $this->_delAttrs + $this->_addAttrs;
+ if (( count($_attrs) > 0) &&
+ !ldap_modify($this->_link, $this->dn(), $_attrs))
{
- // in ldap v3 we need to supply the old attribute values for deleting
- if (@ldap_get_option( $this->_link, LDAP_OPT_PROTOCOL_VERSION, $version) && $version == 3) {
- foreach ( $this->_delAttrs as $k => $v ) {
- if ( $v == '' && $this->exists($k) ) {
- $this->_delAttrs[$k] = $this->get_value( $k );
- }
- }
- }
- if ( !ldap_mod_del($this->_link, $this->dn(), $this->_delAttrs) ) {
- return $this->raiseError("Entry " . $this->dn() . " not modified (attributes not deleted): " .
- ldap_error($this->_link),ldap_errno($this->_link));
- }
+ return $this->raiseError("Entry ". $this->dn(). " not modified (attribs not modified): ". ldap_error($this->_link), ldap_errno($this->_link));
}
-
- // new attributes
- if ((count($this->_addAttrs)) > 0 && !ldap_modify($this->_link, $this->dn(), $this->_addAttrs)) {
- return $this->raiseError( "Entry " . $this->dn() . " not modified (attributes not added): " .
- ldap_error($this->_link),ldap_errno($this->_link));
- }
- return true;
}
}
}

[2006-03-01 04:26 UTC] delatbabel at php dot net

Thank you for taking the time to report a problem with the package.
This problem may have been already fixed by a previous change that
is in the CVS of the package. Please log into CVS with:

cvs -d :pserver:cvsread@cvs.php.net:/repository login

and check out the CVS repository of this package and upgrade

cvs -d :pserver:cvsread@cvs.php.net:/repository co pear/Net_LDAP
pear upgrade pear/Net_LDAP/package2.xml

or

pear upgrade pear/Net_LDAP/package.xml

If you are able to reproduce the bug with the latest CVS,
please change the status back to "Open".
Again, thank you for your continued support of PEAR.

This patch doesn't seem to fit in the current CVS of Net_LDAP. Try the current CVS release and let me know where to apply this patch, or whether it applies at all.