diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote
index b908874b..ef04ed3a 100755
--- a/cdist/conf/type/__user/gencode-remote
+++ b/cdist/conf/type/__user/gencode-remote
@@ -3,6 +3,7 @@
 # 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 # 2011 Nico Schottelius (nico-cdist at schottelius.org)
 # 2013 Daniel Heule (hda at sfs.biz)
+# 2018 Thomas Eckert (tom at it-eckert.de)
 #
 # This file is part of cdist.
 #
@@ -130,7 +131,7 @@ if [ "$state" = "present" ]; then
           echo useradd "$@" "$name"
        fi
     fi
-else
+elif [ "$state" = "absent" ]; then
     if grep -q "^${name}:" "$__object/explorer/passwd"; then
         #user exists, but state != present, so delete it
         if [ -f "$__object/parameter/remove-home" ]; then
@@ -139,4 +140,6 @@ else
             echo userdel "${name}"
         fi
     fi
+else
+    echo "Invalid state $state" >&2
 fi