Index: kernel/classes/ezcontentclass.php
===================================================================
--- kernel/classes/ezcontentclass.php	(revision 21205)
+++ kernel/classes/ezcontentclass.php	(working copy)
@@ -1749,6 +1749,36 @@
         return true;
     }
 
+    /*!
+     Returns an array of ID's of classes containing a specified datatype
+
+     \param $dataTypeString a datatype identification string
+    */
+    static function fetchIDListContainingDatatype( $dataTypeString )
+    {
+        $db = eZDB::instance();
+
+        $version = self::VERSION_STATUS_DEFINED;
+        $escapedDataTypeString = $db->escapeString( $dataTypeString );
+
+        $sql = "SELECT DISTINCT class.id
+                FROM ezcontentclass class, ezcontentclass_attribute attr
+                WHERE attr.contentclass_id=class.id
+                AND class.version=$version
+                AND attr.version=$version
+                AND attr.data_type_string='$escapedDataTypeString'";
+
+        $rows = $db->arrayQuery( $sql );
+
+        $classIDArray = array();
+        foreach ( $rows as $row )
+        {
+            $classIDArray[] = $row['id'];
+        }
+
+        return $classIDArray;
+    }
+
     /// \privatesection
     public $ID;
     // serialized array of translated class names
Index: kernel/classes/ezcontentobjecttreenode.php
===================================================================
--- kernel/classes/ezcontentobjecttreenode.php	(revision 21205)
+++ kernel/classes/ezcontentobjecttreenode.php	(working copy)
@@ -4194,6 +4194,10 @@
 
         $db = eZDB::instance();
         $db->begin();
+
+        $userClassIDArray = eZContentClass::fetchIDListContainingDatatype( 'ezuser' );
+        $usersWereRemoved = false;
+
         foreach ( $deleteIDArray as $deleteID )
         {
             $node = eZContentObjectTreeNode::fetch( $deleteID );
@@ -4218,21 +4222,8 @@
 
             if ( $canRemove )
             {
-                $isUserClass = false;
+                $isUserClass = in_array( $class->attribute( 'id' ), $userClassIDArray );
 
-                $attributes = eZContentClassAttribute::fetchFilteredList(
-                    array( "contentclass_id" => $class->attribute( 'id' ),
-                           "version" => eZContentClass::VERSION_STATUS_DEFINED ), true );
-
-                foreach ( $attributes as $attribute )
-                {
-                    if ( $attribute->attribute( 'data_type_string' ) == 'ezuser' )
-                    {
-                        $isUserClass = true;
-                        break;
-                    }
-                }
-
                 if ( $moveToTrashAllowed and $isUserClass )
                 {
                     $moveToTrashAllowed = false;
@@ -4301,12 +4292,25 @@
 
                         foreach ( $children as $child )
                         {
+                            $childObject = $child->attribute( 'object' );
                             $child->removeNodeFromTree( $moveToTrashTemp );
                             eZContentObject::clearCache();
+
+                            if ( in_array( $childObject->attribute( 'contentclass_id' ), $userClassIDArray ) )
+                            {
+                                eZUser::removeSessionData( $childObject->attribute( 'id' ) );
+                                $usersWereRemoved = true;
+                            }
                         }
                     }
 
                     $node->removeNodeFromTree( $moveToTrashTemp );
+
+                    if ( $isUserClass )
+                    {
+                        eZUser::removeSessionData( $object->attribute( 'id' ) );
+                        $usersWereRemoved = true;
+                    }
                 }
             }
             if ( !$canRemove )
@@ -4337,6 +4341,13 @@
                            'new_main_node_id' => $newMainNodeID );
             $deleteResult[] = $item;
         }
+
+        if ( $usersWereRemoved )
+        {
+            // clean up the user-policy cache
+            eZUser::cleanupCache();
+        }
+
         $db->commit();
 
 
Index: kernel/classes/ezcontentobjecttreenodeoperations.php
===================================================================
--- kernel/classes/ezcontentobjecttreenodeoperations.php	(revision 21205)
+++ kernel/classes/ezcontentobjecttreenodeoperations.php	(working copy)
@@ -87,10 +87,8 @@
         $oldParentObject = $oldParentNode->object();
 
         // clear user policy cache if this was a user object
-        //include_once( "lib/ezutils/classes/ezini.php" );
-        $ini = eZINI::instance();
-        $userClassID = $ini->variable( "UserSettings", "UserClassID" );
-        if ( $object->attribute( 'contentclass_id' ) == $userClassID )
+        $userClassIDArray = eZContentClass::fetchIDListContainingDatatype( 'ezuser' );
+        if ( in_array( $object->attribute( 'contentclass_id' ), $userClassIDArray ) )
         {
             //include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
             eZUser::cleanupCache();
Index: kernel/classes/workflowtypes/event/ezapprove/ezapprovetype.php
===================================================================
--- kernel/classes/workflowtypes/event/ezapprove/ezapprovetype.php	(revision 21205)
+++ kernel/classes/workflowtypes/event/ezapprove/ezapprovetype.php	(working copy)
@@ -264,8 +264,7 @@
         {
 
             /* Get user IDs from approve user groups */
-            $ini = eZINI::instance();
-            $userClassIDArray = array( $ini->variable( 'UserSettings', 'UserClassID' ) );
+            $userClassIDArray = eZContentClass::fetchIDListContainingDatatype( 'ezuser' );
             $approveUserIDArray = array();
             foreach( $approveGroups as $approveUserGroupID )
             {
Index: kernel/content/action.php
===================================================================
--- kernel/content/action.php	(revision 21205)
+++ kernel/content/action.php	(working copy)
@@ -41,8 +41,7 @@
 
 /* We retrieve the class ID for users as this is used in many places in this
  * code in order to be able to cleanup the user-policy cache. */
-$ini = eZINI::instance();
-$userClassID = $ini->variable( "UserSettings", "UserClassID" );
+$userClassIDArray = eZContentClass::fetchIDListContainingDatatype( 'ezuser' );
 
 if ( $module->hasActionParameter( 'LanguageCode' ) )
     $languageCode = $module->actionParameter( 'LanguageCode' );
@@ -457,7 +456,7 @@
     $selectedNode->store();
 
     // clear user policy cache if this was a user object
-    if ( $object->attribute( 'contentclass_id' ) == $userClassID )
+    if ( in_array( $object->attribute( 'contentclass_id' ), $userClassIDArray ) )
     {
         eZUser::cleanupCache();
     }
@@ -737,7 +736,7 @@
         }
         if ( $locationAdded )
         {
-            if ( $object->attribute( 'contentclass_id' ) == $userClassID )
+            if ( in_array( $object->attribute( 'contentclass_id' ), $userClassIDArray ) )
             {
                 eZUser::cleanupCache();
             }
@@ -930,7 +929,7 @@
     //include_once( 'kernel/classes/ezcontentcachemanager.php' );
     eZContentCacheManager::clearObjectViewCacheIfNeeded( $objectID );
     // clear user policy cache if this was a user object
-    if ( $object->attribute( 'contentclass_id' ) == $userClassID )
+    if ( in_array( $object->attribute( 'contentclass_id' ), $userClassIDArray ) )
     {
         eZUser::cleanupCache();
     }
Index: kernel/content/ezcontentoperationcollection.php
===================================================================
--- kernel/content/ezcontentoperationcollection.php	(revision 21205)
+++ kernel/content/ezcontentoperationcollection.php	(working copy)
@@ -185,8 +185,9 @@
             $object->setAttribute( 'published', time() );
         }
         $object->setAttribute( 'modified', time() );
+        $classID = $object->attribute( 'contentclass_id' );
 
-        $class = eZContentClass::fetch( $object->attribute( 'contentclass_id' ) );
+        $class = eZContentClass::fetch( $classID );
         $objectName = $class->contentObjectName( $object );
         $object->setName( $objectName, $versionNum );
         $existingTranslations = $version->translations( false );
@@ -217,11 +218,11 @@
         $db->commit();
 
         /* Check if current class is the user class, and if so, clean up the
-         * user-policy cache */
-        //include_once( "lib/ezutils/classes/ezini.php" );
-        $ini = eZINI::instance();
-        $userClassID = $ini->variable( "UserSettings", "UserClassID" );
-        if ( $object->attribute( 'contentclass_id' ) == $userClassID )
+         * user-policy cache
+         */
+        $userClassIDArray = eZContentClass::fetchIDListContainingDatatype( 'ezuser' );
+
+        if ( in_array( $classID, $userClassIDArray ) )
         {
             //include_once( "kernel/classes/datatypes/ezuser/ezuser.php" );
             eZUser::cleanupCache();
