Index: main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6922)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6927)
@@ -1066,6 +1066,8 @@
             comment = u"AC invalidated for %s" % self.context.student_id
             # Here we know that the ac is in state initialized so we do not
-            # expect an exception
-            invalidate_accesscode(pin,comment)
+            # expect an exception, but the owner might be different
+            if not invalidate_accesscode(pin,comment,self.context.student_id):
+                self.flash('You are not the owner of this access code.')
+                return
             self.context.clr_code = pin
         IWorkflowInfo(self.context).fireTransition('start_clearance')
Index: main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6922)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6927)
@@ -124,7 +124,7 @@
             datetime.now(), 'some_userid', 'CLR', 9.99, 5)
         pins = pin_container[pin_container.keys()[0]].values()
-        self.clrpins = [x.representation for x in pins]
-        self.existing_clrpin = self.clrpins[0]
-        self.existing_clrpin
+        pins[0].owner = u'Hans Wurst'
+        self.existing_clrac = pins[0]
+        self.existing_clrpin = pins[0].representation
         parts = self.existing_clrpin.split('-')[1:]
         self.existing_clrseries, self.existing_clrnumber = parts
@@ -584,4 +584,10 @@
         self.browser.getControl(name="ac_series").value = self.existing_clrseries
         self.browser.getControl(name="ac_number").value = self.existing_clrnumber
+        # Owner is Hans Wurst, AC can't be invalidated
+        self.browser.getControl("Start clearance now").click()
+        self.assertMatches('...You are not the owner of this access code...',
+                           self.browser.contents)
+        # Set the correct owner
+        self.existing_clrac.owner = self.student_id
         self.browser.getControl("Start clearance now").click()
         self.assertMatches('...Clearance process has been started...',
