Index: branches/UserManagement/HeuristicLab.Services.Authentication/AuthenticationService.cs
===================================================================
--- branches/UserManagement/HeuristicLab.Services.Authentication/AuthenticationService.cs	(revision 4740)
+++ branches/UserManagement/HeuristicLab.Services.Authentication/AuthenticationService.cs	(revision 4926)
@@ -13,769 +13,464 @@
     public class AuthenticationService : IAuthenticationService
     {
+
         #region User
 
+
         public DataTransfer.User GetUser(Guid id)
         {
             using (UserManagementDataContext db = new UserManagementDataContext())
             {
-                  var user = db.aspnet_Users.Where(x => x.UserId == id).FirstOrDefault();
-                  var membership = db.aspnet_Memberships.Where(x => x.UserId == id).FirstOrDefault();
-                    
-
-                  return Convert.ToDataTransfer(user, membership);
-                  //Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
-
-                  //var User = from item in UserTable
-                  //           where item.UserId == id
-                  //           select item;
-                  //aspnet_User eUser = User.Single();
-
-                  //User user = Convert.ToDataTransfer((aspnet_User)eUser);
-
-                  //if (user == null) { return null; }
-
-                  //Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
-
-                  //var Membership = from item in MembershipTable
-                  //                 where item.UserId == id
-                  //                 select item;
-
-                  //Membership membership = Convert.ToDataTransfer((aspnet_Membership)eUser.aspnet_Membership);
-
-                  //if (membership == null) { return null; }
-                  //user.Membership = membership;
-
-                  //return user;
-
-            }
-      }
+                var user = db.aspnet_Users.Where(x => x.UserId == id).FirstOrDefault();
+                var membership = db.aspnet_Memberships.Where(x => x.UserId == id).FirstOrDefault();
+
+
+                return Convert.ToDataTransfer(user, membership);
+
+
+            }
+        }
+
+        public IEnumerable<DataTransfer.User> GetUsers(Guid applicationId)
+        {
+            List<DataTransfer.User> userList = new List<DataTransfer.User>();
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var users = db.aspnet_Users.Where(x => x.ApplicationId == applicationId).ToList<aspnet_User>();
+
+                foreach (aspnet_User user in users)
+                {
+                    var membership = db.aspnet_Memberships.Where(x => x.UserId == user.UserId).FirstOrDefault();
+
+                    userList.Add(Convert.ToDataTransfer(user, membership));
+
+                }
+
+
+
+            }
+            return userList;
+        }
+
+        public bool InsertUser(User user)
+        {
+            if (user != null)
+            {
+                using (UserManagementDataContext db = new UserManagementDataContext())
+                {
+
+                    aspnet_User eUser = new aspnet_User();
+                    aspnet_Membership eMembership = new aspnet_Membership();
+
+                    Convert.ToEntity(user, eUser, eMembership);
+                    try
+                    {
+                        db.aspnet_Users.InsertOnSubmit(eUser);
+                        db.aspnet_Memberships.InsertOnSubmit(eMembership);
+                        db.SubmitChanges();
+                    }
+                    catch (Exception ex)
+                    {
+                        return false;
+                    }
+
+                    return true;
+
+
+                }
+
+            }
+            return false;
+        }
+
+        public bool DeleteUser(Guid id)
+        {
+
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var user = db.aspnet_Users.Where(x => x.UserId == id).FirstOrDefault();
+                var membership = db.aspnet_Memberships.Where(x => x.UserId == id).FirstOrDefault();
+                var userinroles = db.aspnet_UsersInRoles.Where(x => x.UserId == id).ToList<aspnet_UsersInRole>();
+                try
+                {
+                    db.aspnet_UsersInRoles.DeleteAllOnSubmit(userinroles);
+                    db.aspnet_Memberships.DeleteOnSubmit(membership);
+                    db.aspnet_Users.DeleteOnSubmit(user);
+                    db.SubmitChanges();
+                }
+                catch (Exception ex)
+                {
+                    return false;
+                }
+                return true;
+
+            }
+            return false;
+        }
+
+
+        public bool UpdateUser(User user)
+        {
+            if (user != null)
+            {
+                using (UserManagementDataContext db = new UserManagementDataContext())
+                {
+
+                    var eUser = db.aspnet_Users.Where(x => x.UserId == user.Id).FirstOrDefault();
+                    var eMembership = db.aspnet_Memberships.Where(x => x.UserId == user.Id).FirstOrDefault();
+                    Convert.ToEntity(user, eUser, eMembership);
+                    try
+                    {
+
+                        db.SubmitChanges();
+                    }
+                    catch (Exception ex)
+                    {
+                        return false;
+                    }
+
+                    return true;
+
+                }
+
+            }
+            return false;
+        }
+
+
 
         #endregion
 
 
-      //public DataTransfer.User GetUser(Guid applicationId, string userName)
-        //{
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
-
-        //            var User = from item in UserTable
-        //                       where item.UserName == userName && item.ApplicationId == applicationId
-        //                       select item;
-
-        //            User user = Convert.ToDataTransfer((aspnet_User)User.Single());
-
-        //            if (user == null) { return null; }
-
-        //            Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
-
-        //            var Membership = from item in MembershipTable
-        //                             where item.UserId == user.UserId
-        //                             select item;
-
-        //            Membership membership = Convert.ToDataTransfer((aspnet_Membership)Membership.Single());
-
-        //            if (membership == null) { return null; }
-        //            user.Membership = membership;
-
-        //            return user;
-
-
-
-
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return null;
-        //        }
-        //       }
-        //}
-
-        //public IEnumerable<DataTransfer.User> GetUsers(Guid applicationId)
-        //{
-        //    List<DataTransfer.User> UserList = new List<DataTransfer.User>();
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
-        //            var Users = from item in UserTable
-        //                        where item.ApplicationId == applicationId
-        //                        select item;
-        //            foreach (var eUser in Users)
-        //            {
-
-        //                User user = Convert.ToDataTransfer(eUser);
-
-        //                if (user== null) { return null; }
-
-        //                //Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
-
-        //                //var Membership = from item in MembershipTable
-        //                //                 where item.UserId == user.UserId
-        //                //                 select item;
-
-        //                Membership membership = Convert.ToDataTransfer((aspnet_Membership)eUser.aspnet_Membership);
-
-        //                if (membership == null) { return null; }
-        //                user.Membership = membership;
-
-        //                UserList.Add(user);
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return new List<User>();
-        //        }
-        //    }
-
-        //    return UserList;
-        //}
-        //public bool InsertUser(User user)
-        //{
-        //    if (user != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-
-        //                Guid? userId = null;
-        //                Application application = GetApplication(user.ApplicationId);
-        //                if(application == null){return false;}
-        //                if (user.Membership == null) { return false; }
-    
-        //                int? passwordFormat = 1;
-        //                int? uniqueEmail = null;
-        //                int result = db.aspnet_Membership_CreateUser(application.ApplicationName, user.UserName, user.Membership.Password, user.Membership.PasswordSalt, user.Membership.Email, user.Membership.PasswordQuestion, user.Membership.PasswordAnswer, user.Membership.IsApproved, DateTime.UtcNow, DateTime.Now, uniqueEmail, passwordFormat, ref userId);
-                                                   
-        //                if (result != 0)
-        //                {
-        //                    return false;
-        //                }
-
-        //                if (userId != null)
-        //                {
-        //                    return true;
-        //                }
-        //                else
-        //                {
-        //                    return false;
-        //                }
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-           
-        //    }
-        //    return false;
-        //}
-        //public bool DeleteUser(Guid id)
-        //{
-
-        //    User user = GetUser(id);
-        //    if (user != null)
-        //    {
-
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                Application application = GetApplication(user.ApplicationId);
-        //                if (application == null)
-        //                {
-        //                    return false;
-        //                }
-
-        //                int? tablesToDeleteFrom = 99;
-        //                int? numTablesDeletedFrom = null;
-        //                db.aspnet_Users_DeleteUser(application.ApplicationName, user.UserName, tablesToDeleteFrom, ref numTablesDeletedFrom);
-                       
-        //                if (numTablesDeletedFrom != null)
-        //                {
-        //                    return true;
-        //                }
-        //                else
-        //                {
-        //                    return false;
-        //                }
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-        //    }
-        //    return false;
-        //}
-
-        //public bool UpdateUser(User user)
-        //{
-           
-        //    if (user != null)
-        //    {
-
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                if (user.Membership == null)
-        //                {
-        //                    return false;
-        //                }
-
-        //                Table<aspnet_User> UserTable = db.GetTable<aspnet_User>();
-
-        //                var User = from item in UserTable
-        //                           where item.UserId == user.UserId
-        //                           select item;
-        //               aspnet_User eUser = ((aspnet_User)User.Single());
-
-
-        //               Table<aspnet_Membership> MembershipTable = db.GetTable<aspnet_Membership>();
-
-        //               var Membership = from item in MembershipTable
-        //                                where item.UserId == user.UserId
-        //                                select item;
-
-        //               aspnet_Membership eMembership = ((aspnet_Membership)Membership.Single());
-
-        //                Convert.ToEntity(user, eUser);
-                        
-        //                Convert.ToEntity(user.Membership, eMembership);
-        //                if (eUser == null)
-        //                {
-        //                   return false;
-        //                }
-        //                if (eMembership == null)
-        //                {
-        //                    return false;
-        //                }
-        //                db.SubmitChanges();
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-        //    } return false;
-        //}
-
-        //#endregion
-
-        //#region Role
-
-        //public Role GetRole(Guid id)
-        //{
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
-
-        //            var Role = from item in RoleTable
-        //                       where item.RoleId == id
-        //                       select item;
-        //            return Convert.ToDataTransfer((aspnet_Role)Role.Single());
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return null;
-        //        }
-        //    }
-        //}
-
-        //public Role GetRole(Guid applicationId, string roleName)
-        //{
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
-
-        //            var Role = from item in RoleTable
-        //                       where item.RoleName == roleName && item.ApplicationId == applicationId
-        //                       select item;
-        //            return Convert.ToDataTransfer((aspnet_Role)Role.Single());
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return null;
-        //        }
-        //    }
-        //}
-
-        //public bool RoleExists(Guid roleId)
-        //{
-        //    if (roleId != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                Role role = GetRole(roleId);
-        //                if (role == null)
-        //                {
-        //                    return false;
-        //                }
-        //                Application application = GetApplication(role.ApplicationId);
-        //                if (application == null)
-        //                {
-        //                    return false;
-        //                }
-
-        //                int result = db.aspnet_Roles_RoleExists(application.ApplicationName, role.RoleName);
-                        
-        //                return (result == 0);
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.Write(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-
-        //    } return false;
-        //}
-
-        //public IEnumerable<Role> GetRoles(Guid applicationId)
-        //{
-        //    List<Role> RoleList = new List<Role>();
-
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //           // db.aspnet_Roles_GetAllRoles(applicationName);
-        //            Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
-
-        //            var Roles = from item in RoleTable
-        //                        where item.ApplicationId == applicationId
-        //                        select item;
-        //            foreach (var Role in Roles)
-        //            {
-        //                RoleList.Add(Convert.ToDataTransfer((aspnet_Role)Role));
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return new List<Role>();
-        //        }
-        //    }
-
-        //    return RoleList;
-        //}
-        
-        //public bool InsertRole(Role role)
-        //{
-        //    if (role != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                Application application = GetApplication(role.ApplicationId);
-        //                if (application == null)
-        //                {
-        //                    return false;
-        //                }
-        //                int result = db.aspnet_Roles_CreateRole(application.ApplicationName, role.RoleName);
-                       
-        //                return (result == 0); // checken, welchen rückgabewert (in db, procedure)
-                      
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-              
-        //    }
-        //    return false;
-        //}
-        //public bool UpdateRole(Role role)
-        //{
-
-        //    if (role != null)
-        //    {
-
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-
-        //                Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>();
-
-        //                var Role = from item in RoleTable
-        //                           where item.RoleId == role.RoleId
-        //                           select item;
-        //                aspnet_Role eRole = ((aspnet_Role)Role.Single());
-
-
-        //                Convert.ToEntity(role, eRole);
-
-        //                if (eRole != null)
-        //                {
-        //                    db.SubmitChanges();
-        //                }
-        //                else
-        //                {
-        //                    return false;
-        //                }
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-        //    } return false;
-        //}
-
-        //public bool DeleteRole(Guid id)
-        //{
-        //    if (id != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                Role role = GetRole(id);
-
-        //                bool deleteOnlyIfRoleIsEmpty = false;
-        //                if (role == null)
-        //                {
-        //                    return false;
-        //                }
-        //                Application application = GetApplication(role.ApplicationId);
-        //                if (application == null)
-        //                {
-        //                    return false;
-        //                }
-        //                db.aspnet_Roles_DeleteRole(application.ApplicationName, role.RoleName, deleteOnlyIfRoleIsEmpty);
-
-                      
-
-        //                return true;
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-        //            }
-        //        }
-              
-        //    }
-        //    return false;
-        //}
-
-        //public bool IsUserInRole(Guid roleId, Guid userId)
-        //{
-        //    if (roleId != null && userId != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-
-        //            try
-        //            {
-        //                User user = GetUser(userId);
-        //                if (user == null) { return false; }
-
-        //                Application application = GetApplication(user.ApplicationId);
-        //                if (application == null) { return false; }
-
-        //                Role role = GetRole(roleId);
-        //                if (role == null) { return false; }
-
-        //                int result = db.aspnet_UsersInRoles_IsUserInRole(application.ApplicationName, user.UserName, role.RoleName);
-                       
-        //                return (result == 0);
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return false;
-
-        //            }
-
-        //        }
-
-        //    } return false;
-        //}
-
-        //public bool AddUserToRole(Guid roleId, Guid userId)
-        //{
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Role role = GetRole(roleId);
-        //            if (role == null)
-        //            {
-        //                return false;
-        //            }
-        //            Application application = GetApplication(role.ApplicationId);
-        //            if (application == null)
-        //            {
-        //                return false;
-        //            }
-        //            User user = GetUser(userId);
-        //            if (user == null)
-        //            {
-        //                return false;
-        //            }
-
-        //            db.aspnet_UsersInRoles_AddUsersToRoles(application.ApplicationName, user.UserName, role.RoleName,DateTime.Now);
-        //            return true;
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return false;
-        //        }
-        //    }
-        
-        //}
-        //public bool RemoveUserFromRole(Guid roleId, Guid userId)
-        //{
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Role role = GetRole(roleId);
-        //            if (role == null)
-        //            {
-        //                return false;
-        //            }
-        //            Application application = GetApplication(role.ApplicationId);
-        //            if (application == null)
-        //            {
-        //                return false;
-        //            }
-        //            User user = GetUser(userId);
-        //            if (user == null)
-        //            {
-        //                return false;
-        //            }
-
-        //           db.aspnet_UsersInRoles_RemoveUsersFromRoles(application.ApplicationName, user.UserName, role.RoleName);
-        //            return true;
-                   
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return false;
-        //        }
-        //    }
-           
-        //}
-        //public IEnumerable<Role> GetRolesForUser(Guid userId)
-        //{
-        //    List<Role> roles = new List<Role>();
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            User user = GetUser(userId);
-        //            if (user == null)
-        //            {
-        //                return roles;
-        //            }
-        //            Application application = GetApplication(user.ApplicationId);
-        //            if (application == null)
-        //            {
-        //                return roles;
-        //            }
-                    
-
-        //            ISingleResult<aspnet_UsersInRoles_GetRolesForUserResult> results = db.aspnet_UsersInRoles_GetRolesForUser(application.ApplicationName,user.UserName);
-        //            foreach (aspnet_UsersInRoles_GetRolesForUserResult userInRole in results)
-        //            {
-        //                roles.Add(GetRole(application.ApplicationId,userInRole.RoleName));
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return new List<Role>();
-        //        }
-        //    }
-            
-        //    return roles;
-        //}
-
-        //public IEnumerable<User> GetUsersInRole(Guid roleId)
-        //{
-        //    List<User> users = new List<User>();
-
-        //    using(UserManagementDataContext db = new UserManagementDataContext()){
-        //        try
-        //        {
-        //            Role role = GetRole(roleId);
-
-        //            if (role != null)
-        //            {
-        //                Application application = GetApplication(role.ApplicationId);
-
-        //                if (application != null)
-        //                {
-
-
-        //                    ISingleResult<aspnet_UsersInRoles_GetUsersInRolesResult> result = db.aspnet_UsersInRoles_GetUsersInRoles(application.ApplicationName, role.RoleName);
-        //                    foreach (aspnet_UsersInRoles_GetUsersInRolesResult usersInRole in result)
-        //                    {
-        //                        users.Add(GetUser(application.ApplicationId,usersInRole.UserName));
-        //                    }
-        //                }
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return new List<User>();
-        //        }
-        //    }
-
-        //    return users;
-        //}
-
-        //#endregion
-
-        //#region Application
-
-        //public Application InsertApplication(Application application)
-        //{
-        //    if (application != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                Guid? applicationId = null;
-        //                int result = db.aspnet_Applications_CreateApplication(application.ApplicationName, ref applicationId);
-        //                Console.WriteLine("result=" + result);
-        //                if (applicationId != null)
-        //                {
-        //                    application.ApplicationId = (Guid)applicationId;
-        //                    return application;
-        //                }
-        //                else
-        //                {
-        //                    return null;
-        //                }
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return null;
-        //            }
-        //        }
-              
-        //    }
-        //    return null;
-        //}
-
-        //public bool DeleteApplication(Application application)
-        //{
-        //    return false;
-        //}
-
-        //public Application GetApplication(Guid id)
-        //{
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Table<aspnet_Application> ApplicationTable = db.GetTable<aspnet_Application>();
-
-        //            var Application = from item in ApplicationTable
-        //                              where item.ApplicationId == id
-        //                              select item;
-        //            return Convert.ToDataTransfer((aspnet_Application)Application.Single());
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return null;
-        //        }
-        //    }
-        //}
-
-        //public IEnumerable<DataTransfer.Application> GetApplications()
-        //{
-        //    List<DataTransfer.Application> ApplicationList = new List<DataTransfer.Application>();
-        //    using (UserManagementDataContext db = new UserManagementDataContext())
-        //    {
-        //        try
-        //        {
-        //            Table<aspnet_Application> ApplicationTable = db.GetTable<aspnet_Application>();
-        //            var Applications = from item in ApplicationTable
-        //                        select item;
-        //            foreach (var eApplication in Applications)
-        //            {
-
-        //                Application application = Convert.ToDataTransfer(eApplication);
-
-        //                if (application == null) { return null; }
-
-
-        //                ApplicationList.Add(application);
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            Debug.WriteLine(ex.InnerException);
-        //            return new List<Application>();
-        //        }
-        //    }
-
-        //    return ApplicationList;
-        //}
-
-
-
-        //#endregion
-
-        //#region Membership
-
-        //public Membership InsertMembership(Membership membership)
-        //{
-
-        //    if (membership != null)
-        //    {
-        //        using (UserManagementDataContext db = new UserManagementDataContext())
-        //        {
-        //            try
-        //            {
-        //                Application application = GetApplication(membership.ApplicationId);
-        //                if (application == null) { return null; }
-
-        //            }
-        //            catch (Exception ex)
-        //            {
-        //                Debug.WriteLine(ex.InnerException);
-        //                return null;
-        //            }
-        //        }
-        //    }
-        //    return null;
-        //}
-
-        //#endregion
+
+        #region Role
+
+        public Role GetRole(Guid id)
+        {
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var role = db.aspnet_Roles.Where(x => x.RoleId == id).FirstOrDefault();
+                return Convert.ToDataTransfer(role);
+            }
+        }
+
+        public IEnumerable<Role> GetRoles(Guid applicationId)
+        {
+            List<DataTransfer.Role> roleList = new List<DataTransfer.Role>();
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var roles = db.aspnet_Roles.Where(x => x.ApplicationId == applicationId).ToList<aspnet_Role>();
+
+                foreach (aspnet_Role role in roles)
+                {
+                    roleList.Add(Convert.ToDataTransfer(role));
+                }
+
+            }
+            return roleList;
+        }
+
+        public bool InsertRole(Role role)
+        {
+
+            if (role != null)
+            {
+                using (UserManagementDataContext db = new UserManagementDataContext())
+                {
+
+                    aspnet_Role eRole = new aspnet_Role();
+
+                    Convert.ToEntity(role, eRole);
+                    try
+                    {
+                        db.aspnet_Roles.InsertOnSubmit(eRole);
+                        db.SubmitChanges();
+                    }
+                    catch (Exception ex)
+                    {
+                        return false;
+                    }
+
+                    return true;
+                }
+
+            }
+            return false;
+        }
+
+        public bool DeleteRole(Guid id)
+        {
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var role = db.aspnet_Roles.Where(x => x.RoleId == id).FirstOrDefault();
+
+
+                try
+                {
+                    db.aspnet_Roles.DeleteOnSubmit(role);
+                    db.SubmitChanges();
+                }
+                catch (Exception ex)
+                {
+                    return false;
+                }
+                return true;
+
+
+            }
+        }
+
+        public bool AddUserToRole(Guid roleId, Guid userId)
+        {
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                try
+                {
+                    aspnet_UsersInRole r = new aspnet_UsersInRole();
+                    r.RoleId = roleId;
+                    r.UserId = userId;
+                    db.aspnet_UsersInRoles.InsertOnSubmit(r);
+                    db.SubmitChanges();
+                    return true;
+                }
+                catch (Exception ex)
+                {
+                    Debug.WriteLine(ex.InnerException);
+                    return false;
+                }
+            }
+        }
+
+        public bool RemoveUserFromRole(Guid roleId, Guid userId)
+        {
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                try
+                {
+                    var role = db.aspnet_UsersInRoles.Where(x => x.RoleId == roleId && x.UserId == userId).FirstOrDefault();
+
+                    db.aspnet_UsersInRoles.DeleteOnSubmit(role);
+                    db.SubmitChanges();
+                    return true;
+
+                }
+                catch (Exception ex)
+                {
+                    Debug.WriteLine(ex.InnerException);
+                    return false;
+                }
+            }
+
+        }
+
+        public IEnumerable<Role> GetRolesForUser(Guid userId)
+        {
+            List<Role> roleList = new List<Role>();
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                try
+                {
+                    var roles = db.aspnet_UsersInRoles.Where(x => x.UserId == userId).ToList<aspnet_UsersInRole>();
+
+                    foreach (aspnet_UsersInRole r in roles)
+                    {
+                        roleList.Add(GetRole(r.RoleId));
+
+                    }
+
+                }
+                catch (Exception ex)
+                {
+                    Debug.WriteLine(ex.InnerException);
+                    return new List<Role>();
+                }
+            }
+
+            return roleList;
+        }
+
+        public IEnumerable<User> GetUsersInRole(Guid roleId)
+        {
+            List<User> userList = new List<User>();
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                try
+                {
+                    var users = db.aspnet_UsersInRoles.Where(x => x.RoleId == roleId).ToList<aspnet_UsersInRole>();
+
+                    foreach (aspnet_UsersInRole u in users)
+                    {
+                        userList.Add(GetUser(u.UserId));
+
+                    }
+
+                }
+                catch (Exception ex)
+                {
+                    Debug.WriteLine(ex.InnerException);
+                    return new List<User>();
+                }
+            }
+
+            return userList;
+        }
+
+
+
+        public bool UpdateRole(Role role)
+        {
+            if (role != null)
+            {
+                using (UserManagementDataContext db = new UserManagementDataContext())
+                {
+
+                    var eRole = db.aspnet_Roles.Where(x => x.RoleId == role.Id).FirstOrDefault();
+
+                    Convert.ToEntity(role, eRole);
+                    try
+                    {
+
+                        db.SubmitChanges();
+                    }
+                    catch (Exception ex)
+                    {
+                        return false;
+                    }
+
+                    return true;
+
+                }
+
+            }
+            return false;
+        }
+
+
+
+        #endregion
+
+
+
+        #region Application
+
+        public bool InsertApplication(Application application)
+        {
+            if (application != null)
+            {
+                using (UserManagementDataContext db = new UserManagementDataContext())
+                {
+
+                    aspnet_Application eApplication = new aspnet_Application();
+
+                    Convert.ToEntity(application, eApplication);
+                    try
+                    {
+                        db.aspnet_Applications.InsertOnSubmit(eApplication);
+                        db.SubmitChanges();
+                    }
+                    catch (Exception ex)
+                    {
+                        return false;
+                    }
+
+                    return true;
+
+                }
+
+            }
+            return false;
+        }
+
+        public bool UpdateApplication(Application application)
+        {
+            if (application != null)
+            {
+                using (UserManagementDataContext db = new UserManagementDataContext())
+                {
+
+                    var eApplication = db.aspnet_Applications.Where(x => x.ApplicationId == application.Id).FirstOrDefault();
+
+                    Convert.ToEntity(application, eApplication);
+                    try
+                    {
+
+                        db.SubmitChanges();
+                    }
+                    catch (Exception ex)
+                    {
+                        return false;
+                    }
+
+                    return true;
+
+                }
+
+            }
+            return false;
+        }
+
+
+        public bool DeleteApplication(Guid applicationId)
+        {
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var users = db.aspnet_Users.Where(x => x.ApplicationId == applicationId).ToList<aspnet_User>();
+                var memberships = db.aspnet_Memberships.Where(x => x.ApplicationId == applicationId).ToList<aspnet_Membership>();
+
+                var roles = db.aspnet_Roles.Where(x => x.ApplicationId == applicationId).ToList<aspnet_Role>();
+                var application = db.aspnet_Applications.Where(x => x.ApplicationId == applicationId).FirstOrDefault();
+
+                try
+                {
+                    foreach (aspnet_User u in users)
+                    {
+                        var userinroles = db.aspnet_UsersInRoles.Where(x => x.UserId == u.UserId).ToList<aspnet_UsersInRole>();
+                        db.aspnet_UsersInRoles.DeleteAllOnSubmit(userinroles);
+                    }
+
+                    db.aspnet_Memberships.DeleteAllOnSubmit(memberships);
+                    db.aspnet_Users.DeleteAllOnSubmit(users);
+                    db.aspnet_Roles.DeleteAllOnSubmit(roles);
+                    db.aspnet_Applications.DeleteOnSubmit(application);
+                    db.SubmitChanges();
+                }
+                catch (Exception ex)
+                {
+                    return false;
+                }
+                return true;
+
+
+            }
+            return false;
+        }
+
+        public Application GetApplication(Guid id)
+        {
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var application = db.aspnet_Applications.Where(x => x.ApplicationId == id).FirstOrDefault();
+                return Convert.ToDataTransfer(application);
+            }
+        }
+
+        public IEnumerable<DataTransfer.Application> GetApplications()
+        {
+            List<DataTransfer.Application> applicationList = new List<DataTransfer.Application>();
+            using (UserManagementDataContext db = new UserManagementDataContext())
+            {
+                var apps = db.aspnet_Applications.ToList<aspnet_Application>();
+
+                foreach (aspnet_Application app in apps)
+                {
+                    applicationList.Add(Convert.ToDataTransfer(app));
+                }
+
+            }
+            return applicationList;
+        }
+
+        #endregion
     }
+
 }
 
Index: branches/UserManagement/HeuristicLab.Services.Authentication/Convert.cs
===================================================================
--- branches/UserManagement/HeuristicLab.Services.Authentication/Convert.cs	(revision 4740)
+++ branches/UserManagement/HeuristicLab.Services.Authentication/Convert.cs	(revision 4926)
@@ -8,51 +8,4 @@
 
         #region User
-
-        /// <summary>
-        /// converts data transfer object to data access objet
-        /// </summary>
-        /// <param name="source">data transfer object</param>
-        /// <returns>data access object</returns>
-        public static aspnet_User ToEntity(User source)
-        {
-            if (source == null) return null;
-            return new aspnet_User()
-            {
-                ApplicationId = source.ApplicationId,
-                UserId = source.Id,
-                UserName = source.Name,
-                //LoweredUserName = source.LoweredUserName,
-                //IsAnonymous = source.IsAnonymous,
-                LastActivityDate = source.LastActivityDate
-            };
-        }
-
-        ///// <summary>
-        ///// converts data transfer object to data access objet
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <returns>data access object</returns>
-        //public static aspnet_Membership ToEntity(User source) {
-        //  if (source == null) return null;
-        //  return new aspnet_Membership() {
-        //    ApplicationId = source.ApplicationId,
-        //    UserId = source.Id,
-        //    Password = source.Password,
-        //    PasswordFormat = 1,
-        //    PasswordSalt = source.PasswordSalt,
-        //    Email = source.Email,
-        //    IsApproved = source.IsApproved,
-        //    IsLockedOut = source.IsLookedOut,
-        //    CreateDate = source.CreateDate,
-        //    LastLoginDate = source.LastLoginDate,
-        //    LastPasswordChangedDate = source.LastPasswordChangeDate,
-        //    LastLockoutDate = source.LastLockoutDate,
-        //    FailedPasswordAttemptCount = 0,
-        //    FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01),
-        //    FailedPasswordAnswerAttemptCount = 0,
-        //    FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01),
-        //    Comment = source.Comment
-        //  };
-        //}
 
         /// <summary>
@@ -94,27 +47,27 @@
             if ((source != null) && (userTarget != null) && (membershipTarget != null))
             {
-              userTarget.ApplicationId = source.ApplicationId;
-              membershipTarget.ApplicationId = source.ApplicationId;
-              userTarget.UserId = source.Id;
-              membershipTarget.UserId = source.Id;
-              userTarget.UserName = source.Name;
-              userTarget.LoweredUserName = source.Name;
-              userTarget.IsAnonymous = false;
-              userTarget.LastActivityDate = source.LastActivityDate;
-              membershipTarget.Password = source.Password;
-              membershipTarget.PasswordFormat = 1;
-              membershipTarget.PasswordSalt = source.PasswordSalt;
-              membershipTarget.Email = source.Email;
-              membershipTarget.IsApproved = source.IsApproved;
-              membershipTarget.IsLockedOut = source.IsLookedOut;
-              membershipTarget.CreateDate = source.CreateDate;
-              membershipTarget.LastLoginDate = source.LastLoginDate;
-              membershipTarget.LastPasswordChangedDate = source.LastPasswordChangeDate;
-              membershipTarget.LastLockoutDate = source.LastLockoutDate;
-              membershipTarget.FailedPasswordAttemptCount = 0;
-              membershipTarget.FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01);
-              membershipTarget.FailedPasswordAnswerAttemptCount = 0;
-              membershipTarget.FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01);
-              membershipTarget.Comment = source.Comment;
+                userTarget.ApplicationId = source.ApplicationId;
+                membershipTarget.ApplicationId = source.ApplicationId;
+                userTarget.UserId = source.Id;
+                membershipTarget.UserId = source.Id;
+                userTarget.UserName = source.Name;
+                userTarget.LoweredUserName = source.Name;
+                userTarget.IsAnonymous = false;
+                userTarget.LastActivityDate = source.LastActivityDate;
+                membershipTarget.Password = source.Password;
+                membershipTarget.PasswordFormat = 1;
+                membershipTarget.PasswordSalt = source.PasswordSalt;
+                membershipTarget.Email = source.Email;
+                membershipTarget.IsApproved = source.IsApproved;
+                membershipTarget.IsLockedOut = source.IsLookedOut;
+                membershipTarget.CreateDate = source.CreateDate;
+                membershipTarget.LastLoginDate = source.LastLoginDate;
+                membershipTarget.LastPasswordChangedDate = source.LastPasswordChangeDate;
+                membershipTarget.LastLockoutDate = source.LastLockoutDate;
+                membershipTarget.FailedPasswordAttemptCount = 0;
+                membershipTarget.FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01);
+                membershipTarget.FailedPasswordAnswerAttemptCount = 0;
+                membershipTarget.FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01);
+                membershipTarget.Comment = source.Comment;
 
             }
@@ -127,147 +80,37 @@
         #region Application
 
-        ///// <summary>
-        ///// converts data transfer object to data access objet
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <returns>data access object</returns>
-        //public static aspnet_Application ToEntity(Application source)
-        //{
-        //    if (source == null) return null;
-        //    return new aspnet_Application()
-        //    {
-        //        ApplicationId = source.ApplicationId,
-        //        ApplicationName = source.ApplicationName,
-        //        LoweredApplicationName = source.LoweredApplicationName,
-        //        Description = source.Description
-        //    };
-        //}
+        /// <summary>
+        /// converts data access object to data transfer object
+        /// </summary>
+        /// <param name="source">data access object</param>
+        /// <returns>data transfer object</returns>
+        public static Application ToDataTransfer(aspnet_Application source)
+        {
+            if (source == null) return null;
+            return new Application()
+            {
+                Id = source.ApplicationId,
+                Name = source.ApplicationName,
+                LoweredApplicationName = source.LoweredApplicationName,
+                Description = source.Description
+            };
+        }
 
-        ///// <summary>
-        ///// converts data access object to data transfer object
-        ///// </summary>
-        ///// <param name="source">data access object</param>
-        ///// <returns>data transfer object</returns>
-        //public static Application ToDataTransfer(aspnet_Application source)
-        //{
-        //    if (source == null) return null;
-        //    return new Application()
-        //    {
-        //        ApplicationId = source.ApplicationId,
-        //        ApplicationName = source.ApplicationName,
-        //        LoweredApplicationName = source.LoweredApplicationName,
-        //        Description = source.Description
-        //    };
-        //}
+        /// <summary>
+        /// converts data transfer object to data access object
+        /// </summary>
+        /// <param name="source">data transfer object</param>
+        /// <param name="target">data access object</param>
+        public static void ToEntity(Application source, aspnet_Application target)
+        {
+            if ((source != null) && (target != null))
+            {
+                target.ApplicationId = source.Id;
+                target.ApplicationName = source.Name;
+                target.LoweredApplicationName = source.LoweredApplicationName;
+                target.Description = source.Description;
+            }
 
-        ///// <summary>
-        ///// converts data transfer object to data access object
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <param name="target">data access object</param>
-        //public static void ToEntity(Application source, aspnet_Application target)
-        //{
-        //    if ((source != null) && (target != null))
-        //    {
-        //        target.ApplicationId = source.ApplicationId;
-        //        target.ApplicationName = source.ApplicationName;
-        //        target.LoweredApplicationName = source.LoweredApplicationName;
-        //        target.Description = source.Description;
-        //    }
-
-        //}
-
-        #endregion
-
-        #region Membership
-
-        ///// <summary>
-        ///// converts data transfer object to data access objet
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <returns>data access object</returns>
-        //public static aspnet_Membership ToEntity(Membership source)
-        //{
-        //    if (source == null) return null;
-        //    return new aspnet_Membership()
-        //    {
-        //        ApplicationId = source.ApplicationId,
-        //        UserId = source.UserId,
-        //        Password = source.Password,
-        //        PasswordAnswer = source.PasswordAnswer,
-        //        PasswordSalt = source.PasswordSalt,
-        //        PasswordQuestion = source.PasswordQuestion,
-               
-        //        Email = source.Email,
-        //        LoweredEmail = source.LoweredEmail,
-        //        IsApproved = source.IsApproved,
-        //        IsLockedOut = source.IsLockedOut,
-        //        CreateDate = source.CreateDate,
-        //        LastLoginDate = source.LastLoginDate,
-        //        LastPasswordChangedDate = source.LastPasswordChangedDate,
-        //        LastLockoutDate = source.LastLockoutDate,
-        //        Comment = source.Comment
-
-                
-        //    };
-        //}
-
-        ///// <summary>
-        ///// converts data access object to data transfer object
-        ///// </summary>
-        ///// <param name="source">data access object</param>
-        ///// <returns>data transfer object</returns>
-        //public static Membership ToDataTransfer(aspnet_Membership source)
-        //{
-        //    if (source == null) return null;
-        //    return new Membership()
-        //    {
-        //        ApplicationId = source.ApplicationId,
-        //        UserId = source.UserId,
-        //        Password = source.Password,
-        //        PasswordAnswer = source.PasswordAnswer,
-        //        PasswordSalt = source.PasswordSalt,
-        //        PasswordQuestion = source.PasswordQuestion,
-               
-        //        Email = source.Email,
-        //        LoweredEmail = source.LoweredEmail,
-        //        IsApproved = source.IsApproved,
-        //        IsLockedOut = source.IsLockedOut,
-        //        CreateDate = source.CreateDate,
-        //        LastLoginDate = source.LastLoginDate,
-        //        LastPasswordChangedDate = source.LastPasswordChangedDate,
-        //        LastLockoutDate = source.LastLockoutDate,
-        //        Comment = source.Comment
-        //    };
-        //}
-
-        ///// <summary>
-        ///// converts data transfer object to data access object
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <param name="target">data access object</param>
-        //public static void ToEntity(Membership source, aspnet_Membership target)
-        //{
-        //    if ((source != null) && (target != null))
-        //    {
-        //        target.ApplicationId = source.ApplicationId;
-        //        target.UserId = source.UserId;
-        //        target.Password = source.Password;
-        //        target.PasswordAnswer = source.PasswordAnswer;
-        //        target.PasswordSalt = source.PasswordSalt;
-        //        target.PasswordQuestion = source.PasswordQuestion;
-               
-        //        target.Email = source.Email;
-        //        target.LoweredEmail = source.LoweredEmail;
-        //        target.IsApproved = source.IsApproved;
-        //        target.IsLockedOut = source.IsLockedOut;
-        //        target.CreateDate = source.CreateDate;
-        //        target.LastLoginDate = source.LastLoginDate;
-        //        target.LastPasswordChangedDate = source.LastPasswordChangedDate;
-        //        target.LastLockoutDate = source.LastLockoutDate;
-        //        target.Comment = source.Comment;
-        //    }
-
-        //}
+        }
 
         #endregion
@@ -275,57 +118,39 @@
         #region Role
 
-        ///// <summary>
-        ///// converts data transfer object to data access objet
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <returns>data access object</returns>
-        //public static aspnet_Role ToEntity(Role source)
-        //{
-        //    if (source == null) return null;
-        //    return new aspnet_Role()
-        //    {
-        //        ApplicationId = source.ApplicationId,
-        //        RoleId = source.RoleId,
-        //        RoleName = source.RoleName,
-        //        LoweredRoleName = source.LoweredRoleName,
-        //        Description = source.Description
-        //    };
-        //}
+        /// <summary>
+        /// converts data access object to data transfer object
+        /// </summary>
+        /// <param name="source">data access object</param>
+        /// <returns>data transfer object</returns>
+        public static Role ToDataTransfer(aspnet_Role source)
+        {
+            if (source == null) return null;
+            return new Role()
+            {
+                ApplicationId = source.ApplicationId,
+                Id = source.RoleId,
+                Name = source.RoleName,
+                Description = source.Description,
+                LoweredRoleName = source.LoweredRoleName,
+            };
+        }
 
-        ///// <summary>
-        ///// converts data access object to data transfer object
-        ///// </summary>
-        ///// <param name="source">data access object</param>
-        ///// <returns>data transfer object</returns>
-        //public static Role ToDataTransfer(aspnet_Role source)
-        //{
-        //    if (source == null) return null;
-        //    return new Role()
-        //    {
-        //        ApplicationId = source.ApplicationId,
-        //        RoleId = source.RoleId,
-        //        RoleName = source.RoleName,
-        //        LoweredRoleName = source.LoweredRoleName,
-        //        Description = source.Description
-        //    };
-        //}
+        /// <summary>
+        /// converts data transfer object to data access object
+        /// </summary>
+        /// <param name="source">data transfer object</param>
+        /// <param name="target">data access object</param>
+        public static void ToEntity(Role source, aspnet_Role target)
+        {
+            if ((source != null) && (target != null))
+            {
+                target.ApplicationId = source.ApplicationId;
+                target.RoleId = source.Id;
+                target.RoleName = source.Name;
+                target.LoweredRoleName = source.LoweredRoleName;
+                target.Description = source.Description;
+            }
 
-        ///// <summary>
-        ///// converts data transfer object to data access object
-        ///// </summary>
-        ///// <param name="source">data transfer object</param>
-        ///// <param name="target">data access object</param>
-        //public static void ToEntity(Role source, aspnet_Role target)
-        //{
-        //    if ((source != null) && (target != null))
-        //    {
-        //        target.ApplicationId = source.ApplicationId;
-        //        target.RoleId = source.RoleId;
-        //        target.RoleName = source.RoleName;
-        //        target.LoweredRoleName = source.LoweredRoleName;
-        //        target.Description = source.Description;
-        //    }
-
-        //}
+        }
 
         #endregion
Index: branches/UserManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.csproj
===================================================================
--- branches/UserManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.csproj	(revision 4740)
+++ branches/UserManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.csproj	(revision 4926)
@@ -4,13 +4,15 @@
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.30703</ProductVersion>
+    <ProductVersion>8.0.50727</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{FF763830-EE9B-4FF7-9A55-4E2552E20C9A}</ProjectGuid>
+    <ProjectGuid>{0E7ADDD6-C7EA-45F6-A7ED-48041ABF1A87}</ProjectGuid>
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>HeuristicLab.Services.Authentication</RootNamespace>
     <AssemblyName>HeuristicLab.Services.Authentication</AssemblyName>
+    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <StartArguments>/client:"WcfTestClient.exe"</StartArguments>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -32,21 +34,23 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.CSharp" />
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Data" />
     <Reference Include="System.Data.Linq" />
-    <Reference Include="System.Data.Services" />
     <Reference Include="System.Runtime.Serialization" />
     <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Xml" />
     <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Convert.cs" />
+    <Compile Include="Interface\IAuthenticationService.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="AuthenticationService.cs" />
-    <Compile Include="Convert.cs" />
-    <Compile Include="Interfaces\IAuthenticationService.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="HeuristicLab.snk" />
   </ItemGroup>
   <ItemGroup>
@@ -60,8 +64,14 @@
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <WCFMetadata Include="Service References\" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <VisualStudio>
+      <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
+        <WcfProjectProperties>
+          <AutoStart>True</AutoStart>
+        </WcfProjectProperties>
+      </FlavorProperties>
+    </VisualStudio>
+  </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
Index: branches/UserManagement/HeuristicLab.Services.Authentication/Interfaces/IAuthenticationService.cs
===================================================================
--- branches/UserManagement/HeuristicLab.Services.Authentication/Interfaces/IAuthenticationService.cs	(revision 4740)
+++ branches/UserManagement/HeuristicLab.Services.Authentication/Interfaces/IAuthenticationService.cs	(revision 4926)
@@ -15,27 +15,25 @@
         User GetUser(Guid id);
 
-        //[OperationContract]
-        //User GetUser(Guid applicationId, string userName);
+      
+        [OperationContract]
+        IEnumerable<User> GetUsers(Guid applicationId);
 
-        //[OperationContract]
-        //IEnumerable<User> GetUsers(Guid applicationId);
+        [OperationContract]
+        bool InsertUser(User user);
 
-        //[OperationContract]
-        //bool InsertUser(User user);
+        [OperationContract]
+        bool DeleteUser(Guid id);
 
-        //[OperationContract]
-        //bool DeleteUser(Guid id);
+        [OperationContract]
+        bool UpdateUser(User user);
 
-        //[OperationContract]
-        //bool UpdateUser(User user);
+        [OperationContract]
+        bool AddUserToRole(Guid roleId, Guid userId);
 
-        //[OperationContract]
-        //bool AddUserToRole(Guid roleId, Guid userId);
+        [OperationContract]
+        bool RemoveUserFromRole(Guid roleId, Guid userId);
 
-        //[OperationContract]
-        //bool RemoveUserFromRole(Guid roleId, Guid userId);
-
-        //[OperationContract]
-        //IEnumerable<Role> GetRolesForUser(Guid userId);
+        [OperationContract]
+        IEnumerable<Role> GetRolesForUser(Guid userId);
 
         #endregion
@@ -43,55 +41,43 @@
         #region Role
 
-        //[OperationContract]
-        //Role GetRole(Guid id);
-        
-        //[OperationContract]
-        //Role GetRole(Guid applicationId, string roleName);
+        [OperationContract]
+        Role GetRole(Guid id);
 
-        //[OperationContract]
-        //IEnumerable<Role> GetRoles(Guid applicationId);
+     
 
-        //[OperationContract]
-        //bool RoleExists(Guid roleId);
+        [OperationContract]
+        IEnumerable<Role> GetRoles(Guid applicationId);
 
-        //[OperationContract]
-        //bool IsUserInRole(Guid roleId, Guid userId);
-        
-        //[OperationContract]
-        //bool InsertRole(Role role);
+        [OperationContract]
+        bool InsertRole(Role role);
 
-        //[OperationContract]
-        //bool UpdateRole(Role role);
+        [OperationContract]
+        bool UpdateRole(Role role);
 
-        //[OperationContract]
-        //bool DeleteRole(Guid id);
+        [OperationContract]
+        bool DeleteRole(Guid id);
 
-        //[OperationContract]
-        //IEnumerable<User> GetUsersInRole(Guid roleId);
-       
+        [OperationContract]
+        IEnumerable<User> GetUsersInRole(Guid roleId);
+
         #endregion
 
         #region Application
 
-        //[OperationContract]
-        //Application GetApplication(Guid id);
+        [OperationContract]
+        Application GetApplication(Guid id);
 
-        //[OperationContract]
-        //Application InsertApplication(Application application);
+        [OperationContract]
+        bool InsertApplication(Application application);
 
-        //[OperationContract]
-        //bool DeleteApplication(Application application);
+        [OperationContract]
+        bool DeleteApplication(Guid id);
 
-        // [OperationContract]
-        //IEnumerable<DataTransfer.Application> GetApplications();
+        [OperationContract]
+        IEnumerable<DataTransfer.Application> GetApplications();
 
         #endregion
 
-        #region Membership
-
-        //[OperationContract]
-        //Membership InsertMembership(Membership membership);
-
-        #endregion
+        
     }
 }
Index: branches/UserManagement/HeuristicLab.Services.Authentication/Properties/AssemblyInfo.cs
===================================================================
--- branches/UserManagement/HeuristicLab.Services.Authentication/Properties/AssemblyInfo.cs	(revision 4740)
+++ branches/UserManagement/HeuristicLab.Services.Authentication/Properties/AssemblyInfo.cs	(revision 4926)
@@ -6,10 +6,10 @@
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
-[assembly: AssemblyTitle("HeuristicLab.Services.Authentication.Service")]
+[assembly: AssemblyTitle("HeuristicLab.Services.Authentication")]
 [assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("HeuristicLab.Services.Authentication.Service")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab.Services.Authentication")]
+[assembly: AssemblyCopyright("Copyright ©  2010")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
@@ -21,5 +21,5 @@
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("d0959a99-16df-429c-b9f5-50888717e468")]
+[assembly: Guid("c63abe4c-1254-463f-91f8-ba4972bc0f52")]
 
 // Version information for an assembly consists of the following four values:
Index: branches/UserManagement/HeuristicLab.Services.Authentication/app.config
===================================================================
--- branches/UserManagement/HeuristicLab.Services.Authentication/app.config	(revision 4926)
+++ branches/UserManagement/HeuristicLab.Services.Authentication/app.config	(revision 4926)
@@ -0,0 +1,94 @@
+<?xml version="1.0"?>
+<configuration>
+  <connectionStrings>
+    <add name="HeuristicLab.Authentication"
+         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication" />
+  </connectionStrings>
+
+  <system.web>
+    <compilation debug="true" />
+    <membership>
+      <providers>
+        <clear />
+        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication"
+             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
+             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
+             applicationName="HeuristicLab.Authentication" />
+      </providers>
+    </membership>
+    <roleManager enabled="true">
+      <providers>
+        <clear />
+        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication"
+             applicationName="HeuristicLab.Authentication" />
+      </providers>
+    </roleManager>
+  </system.web>
+
+  <system.serviceModel>
+    <bindings>
+      <netTcpBinding>
+        <binding name="DefaultNetTcpBinding" openTimeout="00:00:30" receiveTimeout="00:00:30"
+          sendTimeout="00:00:30" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
+          <readerQuotas maxArrayLength="2147483647" />
+          <reliableSession inactivityTimeout="00:00:30" enabled="false" />
+          <security mode="Message">
+            <message clientCredentialType="UserName" />
+          </security>
+        </binding>
+      </netTcpBinding>
+      <wsHttpBinding>
+        <binding name="DefaultWsHttpBinding" maxReceivedMessageSize="200000000">
+          <readerQuotas maxArrayLength="200000000" maxBytesPerRead="200000000" />
+          <security mode="Message">
+            <message clientCredentialType="UserName" />
+          </security>
+        </binding>
+      </wsHttpBinding>
+      <mexHttpBinding>
+        <binding name="DefaultMexHttpBinding" />
+      </mexHttpBinding>
+    </bindings>
+
+    
+    <behaviors>
+      <serviceBehaviors>
+        <behavior name="DefaultServiceBehavior">
+          <serviceMetadata httpGetEnabled="true" />
+          <serviceDebug includeExceptionDetailInFaults="true" />
+          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider" />
+          <serviceCredentials>
+            <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" />
+            <userNameAuthentication  userNamePasswordValidationMode="Windows" />
+          </serviceCredentials>
+        </behavior>
+      </serviceBehaviors>
+    </behaviors>
+
+    <services>
+      <service behaviorConfiguration="DefaultServiceBehavior" name="HeuristicLab.Services.Authentication.AuthenticationService">
+        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="DefaultMexHttpBinding"
+          name="mexHttpBinding" contract="IMetadataExchange">
+          <identity>
+            <certificate encodedValue="AwAAAAEAAAAUAAAAD/AlkYJw/OUhl6D/9w8mjJBh39kgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhAdEzTisaf2sEZxrqYZfYtCMAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMDgyMDIyMzIwOFoXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPkfCSLRX8/4F+Z4ys43yZ4MMzjB44cMakPz4Nri+mEB5n2z/0GFatCYzkI2f/nniWqVrBYjHkjsZy2EZioHu4wa99c1XEGJnFNDuNn6ESkfEyhyF4+OqKGnpK9HNrw7OWMuqn2oOh0iFd9fl6FTAm+Y0p3LP+38BuYzpCniqqdwIDAQABo0kwRzBFBgNVHQEEPjA8gBDvi8Rgio9v+mr58TiAvqF5oRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghAdEzTisaf2sEZxrqYZfYtCMAkGBSsOAwIdBQADgYEANdGlvHKeUptfNu9I0wgA5qjmVB+JDldOAkrfM0R+4IcVQ06y5K7P07uxQAV7+rhnDLgLyFJunUHgzbfjsjFy7vjwtoieXA5j0AYlm4AHR7dHt4HVgkIMYt8XOCqMw5jjFX91xJ89tC7mM9zYR48N9T5QSeMGo+f+JzybeLWxnNs=" />
+          </identity>
+        </endpoint>
+        <endpoint binding="wsHttpBinding" bindingConfiguration="DefaultWsHttpBinding"
+          name="wsHttpBinding" contract="HeuristicLab.Services.Authentication.IAuthenticationService">
+          <identity>
+            <certificate encodedValue="AwAAAAEAAAAUAAAAD/AlkYJw/OUhl6D/9w8mjJBh39kgAAAAAQAAAPIBAAAwggHuMIIBW6ADAgECAhAdEzTisaf2sEZxrqYZfYtCMAkGBSsOAwIdBQAwFDESMBAGA1UEAxMJbG9jYWxob3N0MB4XDTEwMDgyMDIyMzIwOFoXDTM5MTIzMTIzNTk1OVowFDESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPkfCSLRX8/4F+Z4ys43yZ4MMzjB44cMakPz4Nri+mEB5n2z/0GFatCYzkI2f/nniWqVrBYjHkjsZy2EZioHu4wa99c1XEGJnFNDuNn6ESkfEyhyF4+OqKGnpK9HNrw7OWMuqn2oOh0iFd9fl6FTAm+Y0p3LP+38BuYzpCniqqdwIDAQABo0kwRzBFBgNVHQEEPjA8gBDvi8Rgio9v+mr58TiAvqF5oRYwFDESMBAGA1UEAxMJbG9jYWxob3N0ghAdEzTisaf2sEZxrqYZfYtCMAkGBSsOAwIdBQADgYEANdGlvHKeUptfNu9I0wgA5qjmVB+JDldOAkrfM0R+4IcVQ06y5K7P07uxQAV7+rhnDLgLyFJunUHgzbfjsjFy7vjwtoieXA5j0AYlm4AHR7dHt4HVgkIMYt8XOCqMw5jjFX91xJ89tC7mM9zYR48N9T5QSeMGo+f+JzybeLWxnNs=" />
+          </identity>
+        </endpoint>
+        <host>
+          <baseAddresses>
+            <add baseAddress="http://localhost:8732/Design_Time_Addresses/HeuristicLab.Services.Authentication/AuthenticationService" />
+          </baseAddresses>
+        </host>
+      </service>
+    </services>
+  </system.serviceModel>
+
+  <startup>
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
+  </startup>
+</configuration>
