diff --git a/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.module b/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.module
index e123181..e5907ff 100644
--- a/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.module
+++ b/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.module
@@ -194,17 +194,21 @@ function simplesamlphp_auth_init() {
               $userinfo = array('roles' => $roles);
               $user = user_save($user, $userinfo); // @todo - Fjernet rolle-delen her da den gav en bra feilmelding når roller ikke finnes ;)
             }
+            
+            if (function_exists('rules_invoke_event')) {
+              rules_invoke_event('simplesamlphp_auth_rules_action_register', $user); 
+            }
 
             drupal_set_message(t("Welcome. Since this is your first time logging in, we've automatically provisioned an account for you."), 'status');
 
-            }
-            else {
-              // We are not allowed to register new users on the site through simpleSAML.
-              // We let the user know about this and redirect to the user/login page.
-              $msg = t("We are sorry. While you have successfully authenticated, you are not yet entitled to access this site. Please ask the site administrator to provision access for you.");
-              drupal_set_message($msg);
-              $_simplesamlphp_auth_as->logout('/?msg=' . $msg);
-            }
+          }
+          else {
+            // We are not allowed to register new users on the site through simpleSAML.
+            // We let the user know about this and redirect to the user/login page.
+            $msg = t("We are sorry. While you have successfully authenticated, you are not yet entitled to access this site. Please ask the site administrator to provision access for you.");
+            drupal_set_message($msg);
+            $_simplesamlphp_auth_as->logout('/?msg=' . $msg);
+          }
         }
         else {
           // If successfully logged into Drupal.
@@ -225,6 +229,10 @@ function simplesamlphp_auth_init() {
             // No need to evaluate roles, populate the user object.
             $user = $ext_user;
           }
+          
+          if (function_exists('rules_invoke_event')) {
+            rules_invoke_event('simplesamlphp_auth_rules_action_login', $user); 
+          }
 
           $msg = t("Welcome back.");
           drupal_set_message($msg, 'status');
diff --git a/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.rules.inc b/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.rules.inc
index e69de29..e72ca72 100644
--- a/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.rules.inc
+++ b/html/sites/all/modules/simplesamlphp_auth/simplesamlphp_auth.rules.inc
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * @file
+ * Integration with Rules module.
+ */
+
+/**
+ * Implementation of hook_rules_event_info().
+ * @ingroup rules
+ */
+function simplesamlphp_auth_rules_event_info() {
+  $defaults = array(
+    'group' => t('User'),
+    'module' => 'simplesamlphp_auth',
+  );
+ 
+  return array(
+    'simplesamlphp_auth_rules_action_register' => $defaults + array(
+      'label' => t('Register user via simpleSAMLphp'),
+      'group' => t('User'),
+      'variables' => array(
+        'user' => array('type' => 'user', 'label' => t('Logged in user')),
+      ),
+    ),
+    'simplesamlphp_auth_rules_action_login' => $defaults + array(
+      'label' => t('Login user via simpleSAMLphp'),
+      'group' => t('User'),
+      'variables' => array(
+        'user' => array('type' => 'user', 'label' => t('User')),
+      ),
+    ),
+  );
+}
