diff --git a/include/class_exceptions.inc b/include/class_exceptions.inc
index ac67ff135b72e9ae4e086019cdb4211aeb49c82d..16eeea5ada2acca4fcd606073314b4123478176b 100644
--- a/include/class_exceptions.inc
+++ b/include/class_exceptions.inc
@@ -44,6 +44,13 @@ class LdapGeneralizedTimeBadFormatException extends FusionDirectoryException
 {
 }
 
+/*! \class InvalidValueException
+    \brief Exception class which can be thrown if an attribute is set to a value with a non-compatible type
+*/
+class InvalidValueException extends FusionDirectoryException
+{
+}
+
 class NonExistingObjectTypeException extends FusionDirectoryException
 {
 }
diff --git a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc
index 0e0736c1572c8b195ebc9d03b63beefb8a5d706d..9d0b9000c1eb1ae9e6a5e4a520868d8a21cd5cb6 100644
--- a/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc
+++ b/include/simpleplugin/attributes/class_BaseSelectorAttribute.inc
@@ -120,6 +120,13 @@ class BaseSelectorAttribute extends Attribute
     }
   }
 
+  function checkValue($value)
+  {
+    if (!is_string($value) && (!is_object($value) || !method_exists($value, '__toString' ))) {
+      throw new InvalidValueException(_('Base field value should always be a string'));
+    }
+  }
+
   function setValue ($value)
   {
     parent::setValue($value);
diff --git a/include/simpleplugin/attributes/class_SetAttribute.inc b/include/simpleplugin/attributes/class_SetAttribute.inc
index b0a546d3ffba3c7e2a9c9c78bc8663f75885f531..7871fcf64e2405af8995f0e441292e0d4dd73efb 100644
--- a/include/simpleplugin/attributes/class_SetAttribute.inc
+++ b/include/simpleplugin/attributes/class_SetAttribute.inc
@@ -339,6 +339,13 @@ class SetAttribute extends Attribute
   {
     $this->size = $size;
   }
+
+  function checkValue($value)
+  {
+    if (!is_array($value)) {
+      throw new InvalidValueException(sprintf(_('SetAttribute "%s" was set to a non-compatible value'), $this->getLabel()));
+    }
+  }
 }
 
 /*!
diff --git a/include/simpleplugin/attributes/class_StringAttribute.inc b/include/simpleplugin/attributes/class_StringAttribute.inc
index a283089ac21b03c21ca4c3495bf277d9a45d30ee..97471ab52dc59df6deb3983af915fbd34aff5401 100644
--- a/include/simpleplugin/attributes/class_StringAttribute.inc
+++ b/include/simpleplugin/attributes/class_StringAttribute.inc
@@ -108,6 +108,13 @@ class StringAttribute extends Attribute
     return $this->autocomplete;
   }
 
+  function checkValue($value)
+  {
+    if (!is_scalar($value) && (!is_object($value) || !method_exists($value, '__toString' ))) {
+      throw new InvalidValueException(sprintf(_('StringAttribute "%s" was set to a non-compatible value'), $this->getLabel()));
+    }
+  }
+
   function setValue ($value)
   {
     if ($this->trim) {
diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc
index 0e53aef74fa59963b021b5e217939c940f2bbd62..65b24789163b186909fcf31268ced3f92fb9f3e2 100644
--- a/include/simpleplugin/class_Attribute.inc
+++ b/include/simpleplugin/class_Attribute.inc
@@ -154,8 +154,14 @@ class Attribute
     return $this->inLdap;
   }
 
+  function checkValue ($value)
+  {
+    /* Should throw InvalidValueException if needed */
+  }
+
   function setValue ($value)
   {
+    $this->checkValue($value);
     $old_value    = $this->value;
     $this->value  = $value;
     if (($this->submitForm != FALSE) && ($this->submitForm !== TRUE) && ($old_value != $value) && is_object($this->plugin)) {