public void Import(WindowsIdentity identity) { var service = new EFMembershipService(); if (service.GetUser(identity.Name) == null) { service.CreateUser(identity.Name, "imported", identity.Name, "None", "None"); if (!String.Equals(ConfigurationManager.AppSettings["ShouldImportWindowsUserAsAdministrator"], "true", StringComparison.InvariantCultureIgnoreCase)) return; var roleProvider = new EFRoleProvider(); roleProvider.AddUsersToRoles(new[] { identity.Name }, new[] { Definitions.Roles.Administrator }); } }
protected void InitialiseTestObjects() { _teams = new EFTeamRepository { CreateContext = () => _connection.GetContext() }; _users = new EFMembershipService { CreateContext = () => _connection.GetContext() }; _repos = new EFRepositoryRepository { CreateContext = () => _connection.GetContext() }; _roles = new EFRoleProvider { CreateContext = () => _connection.GetContext() }; _service = new RepositoryPermissionService { Repository = _repos, TeamRepository = _teams, RoleProvider = _roles }; new AutomaticUpdater().RunWithContext(_connection.GetContext()); }