Index: branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs
===================================================================
--- branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs	(revision 3963)
+++ branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs	(revision 3964)
@@ -24,4 +24,5 @@
         }
         db.SubmitChanges();
+        db.Dispose();
       }
     }
@@ -49,4 +50,5 @@
         db.HeuristicLabRole.InsertOnSubmit(role);
         db.SubmitChanges();
+        db.Dispose();
       }
     }
@@ -74,8 +76,10 @@
       List<string> roleList = new List<string>();
 
-      List<HeuristicLabRole> roles = new List<HeuristicLabRole>(DatabaseUtil.createDataClassesDataContext().HeuristicLabRole.Select(r => r));
+      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
+      List<HeuristicLabRole> roles = new List<HeuristicLabRole>(db.HeuristicLabRole.Select(r => r));
       foreach (HeuristicLabRole r in roles) {
         roleList.Add(r.RoleName);
       }
+      db.Dispose();
 
       return roleList.ToArray();
@@ -100,19 +104,12 @@
     }
 
-
-    /// <summary>
-    /// true if given username has exists in given Role, else false
-    /// </summary>
-    /// <param name="username"></param>
-    /// <param name="roleName"></param>
-    /// <returns>bool</returns>
     public override bool IsUserInRole(string username, string roleName) {
-        bool returnValue = false;
-        DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext();
-        if (username != null && roleName != null)
-        {
-            returnValue = (context.HeuristicLabUserRole.Count(ur => ur.HeuristicLabRole.RoleName == roleName && ur.HeuristicLabUser.UserName == username) > 0);
-        }
-        return returnValue;
+      bool returnValue = false;
+      DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext();
+      if (username != null && roleName != null) {
+        returnValue = (context.HeuristicLabUserRole.Count(ur => ur.HeuristicLabRole.RoleName == roleName && ur.HeuristicLabUser.UserName == username) > 0);
+      }
+      context.Dispose();
+      return returnValue;
     }
 
Index: branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs
===================================================================
--- branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs	(revision 3963)
+++ branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs	(revision 3964)
@@ -101,25 +101,23 @@
     [TestMethod()]
     public void IsUserInRoleTest() {
-        HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
-        Dictionary<string, Persistence.HeuristicLabUser> users = new Dictionary<string, Persistence.HeuristicLabUser>();
-        List<string> roles = new List<string>();
-        users.Add("mholper", new Persistence.HeuristicLabUser("mholper", "foo", "password", "comment"));
-
-        roles.Add("admin");
-        roles.Add("users");
-        foreach (string role in roles)
-        {
-            target.CreateRole(role);
-        }
-        foreach (Persistence.HeuristicLabUser user in users.Values)
-        {
-            db.HeuristicLabUsers.InsertOnSubmit(user);
-        }
-        db.SubmitChanges();
-        string[] rolesToTest = new string[1];
-        rolesToTest[0] = "admin";
-        target.AddUsersToRoles(users.Keys.ToArray(), rolesToTest); // roles.ToArray());
-        Assert.IsTrue(target.IsUserInRole("mholper", "admin"));
-        Assert.IsFalse(target.IsUserInRole("mholper", "user"));
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value
+      Dictionary<string, Persistence.HeuristicLabUser> users = new Dictionary<string, Persistence.HeuristicLabUser>();
+      List<string> roles = new List<string>();
+      users.Add("mholper", new Persistence.HeuristicLabUser("mholper", "foo", "password", "comment"));
+
+      roles.Add("admin");
+      roles.Add("users");
+      foreach (string role in roles) {
+        target.CreateRole(role);
+      }
+      foreach (Persistence.HeuristicLabUser user in users.Values) {
+        db.HeuristicLabUsers.InsertOnSubmit(user);
+      }
+      db.SubmitChanges();
+      string[] rolesToTest = new string[1];
+      rolesToTest[0] = "admin";
+      target.AddUsersToRoles(users.Keys.ToArray(), rolesToTest); // roles.ToArray());
+      Assert.IsTrue(target.IsUserInRole("mholper", "admin"));
+      Assert.IsFalse(target.IsUserInRole("mholper", "user"));
     }
 
@@ -173,6 +171,6 @@
       Assert.IsTrue(rolesForUser.Contains("testRole1"));
 
-      
-      
+
+
     }
 
@@ -182,5 +180,5 @@
     [TestMethod()]
     public void GetAllRolesTest() {
-      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); 
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
       List<string> roleNames = new List<string>();
       roleNames.Add("Pascal");
@@ -193,6 +191,5 @@
       target.CreateRole(null);
       string[] roles = target.GetAllRoles();
-      foreach(string role in roles)
-      {
+      foreach (string role in roles) {
         Assert.IsTrue(roleNames.Remove(role));
       }
@@ -219,5 +216,5 @@
       Assert.IsTrue(target.FindUsersInRole("testRole", "dummyUser3").Length == 0);
 
-      target.AddUsersToRoles(new string[] { "dummyUser", "dummyUser2" }, new string[] {"testRole" });
+      target.AddUsersToRoles(new string[] { "dummyUser", "dummyUser2" }, new string[] { "testRole" });
       Assert.IsTrue(target.FindUsersInRole("testRole", "dummyUser").Length == 2);
       Assert.IsTrue(target.FindUsersInRole("testRole", "dummyUser2").Length == 1);
@@ -247,5 +244,5 @@
     [TestMethod()]
     public void CreateRoleTest() {
-      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); 
+      HeuristicLabRoleProvider target = new HeuristicLabRoleProvider();
       target.CreateRole("role1");
       target.CreateRole("role2");
@@ -257,5 +254,5 @@
 
     protected int getUserRolesCount() {
-      return db.HeuristicLabUserRole.Count();      
+      return db.HeuristicLabUserRole.Count();
     }
 
@@ -279,6 +276,5 @@
       Assert.IsTrue(getUserRolesCount() == 0);
 
-      foreach (string role in roles)
-      {
+      foreach (string role in roles) {
         target.CreateRole(role);
       }
