public function modify($entry, $parms = array())
    {
        if (is_string($entry)) {
            $entry = $this->getEntry($entry);
            if (self::isError($entry)) {
                return $entry;
            }
        }
        if (!$entry instanceof Net_LDAP2_Entry) {
            return PEAR::raiseError("Parameter is not a string nor an entry object!");
        }

        // Perform changes mentioned separately
        foreach (array('add', 'delete', 'replace') as $action) {
            if (isset($parms[$action])) {
                $msg = $entry->$action($parms[$action]);
                if (self::isError($msg)) {
                    return $msg;
                }
                $entry->setLDAP($this);

                // Because the @ldap functions are called inside Net_LDAP2_Entry::update(),
                // we have to trap the error codes issued from that if we want to support
                // reconnection.
                while (true) {
                    $msg = $entry->update();

                    if (self::isError($msg)) {
                        // We have a failure.  What type?  We may be able to reconnect
                        // and try again.
                        $error_code = $msg->getCode();
                        $error_name = Net_LDAP2::errorMessage($error_code);

                        if ((Net_LDAP2::errorMessage($error_code) === 'LDAP_OPERATIONS_ERROR') &&
                            ($this->_config['auto_reconnect'])) {

                            // The server has become disconnected before trying the
                            // operation.  We should try again, possibly with a different
                            // server.
                            $this->_link = false;
                            $this->performReconnect();

                        } else {

                            // Errors other than the above catched are just passed
                            // back to the user so he may react upon them.
                            return PEAR::raiseError("Could not modify entry: ".$msg->getMessage());
                        }
                    } else {
                        // modification succeedet, evaluate next change
                        break;
                    }
                }
            }
        }

        // perform combined changes in 'changes' array
        if (isset($parms['changes']) && is_array($parms['changes'])) {
            foreach ($parms['changes'] as $action => $value) {

                // Because the @ldap functions are called inside Net_LDAP2_Entry::update,
                // we have to trap the error codes issued from that if we want to support
                // reconnection.
                while (true) {
                    $msg = $this->modify($entry, array($action => $value));

                    if (self::isError($msg)) {
                        // We have a failure.  What type?  We may be able to reconnect
                        // and try again.
                        $error_code = $msg->getCode();
                        $error_name = Net_LDAP2::errorMessage($error_code);

                        if ((Net_LDAP2::errorMessage($error_code) === 'LDAP_OPERATIONS_ERROR') &&
                            ($this->_config['auto_reconnect'])) {

                            // The server has become disconnected before trying the
                            // operation.  We should try again, possibly with a different
                            // server.
                            $this->_link = false;
                            $this->performReconnect();

                        } else {
                            // Errors other than the above catched are just passed
                            // back to the user so he may react upon them.
                            return $msg;
                        }
                    } else {
                        // modification succeedet, evaluate next change
                        break;
                    }
                }
            }
        }

        return true;
    }