private static void Import(WindowsIdentity identity) { var service = new EFMembershipService(); if (service.GetUser(identity.Name) != null) { RefreshTeams(identity); return; } service.CreateUser(identity.Name, "imported", identity.Name, "None", "None"); RefreshTeams(identity); 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(() => _connection.GetContext()); _users = new EFMembershipService(() => _connection.GetContext()); _repos = new EFRepositoryRepository(() => _connection.GetContext()); _roles = new EFRoleProvider(() => _connection.GetContext()); _service = new RepositoryPermissionService(_repos, _roles, _teams); new AutomaticUpdater().RunWithContext(_connection.GetContext(), Substitute.For <IAuthenticationProvider>()); }
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()); }
public void Initialize() { _connection = new SqlServerTestConnection(); _provider = EFRoleProvider.FromCreator(() => _connection.GetContext()); new AutomaticUpdater().RunWithContext(_connection.GetContext()); }
public void Initialize() { _provider = new EFRoleProvider(); _provider.ApplicationName = "SalesMgt"; _provider.ConnectionString = ConfigurationManager.ConnectionStrings["membershipDb"].ConnectionString; }
public void Initialize(EFRoleProvider <TRole, TUserRole, TRoleKey> Provider) { this.Provider = Provider; //Role Table var roleType = typeof(TRole); var tblNameAttr = roleType.GetCustomAttributes(typeof(TableAttribute), true); var noPrefixAttr = roleType.GetCustomAttributes(typeof(NoPrefixAttribute), true); RoleTableNoPrefix = noPrefixAttr != null && noPrefixAttr.Length > 0; var first = tblNameAttr.FirstOrDefault() as TableAttribute; if (first != null) { RoleTableName = first; } else { RoleTableName = new TableAttribute(roleType.Name.Trim().Replace(" ", "")); } if (!RoleTableNoPrefix && !string.IsNullOrWhiteSpace(Provider.TablePrefix)) { var schema = RoleTableName.Schema; RoleTableName = new TableAttribute(Provider.TablePrefix + RoleTableName.Name); if (schema != null) { RoleTableName.Schema = schema; } } RoleType = roleType; //User Role Table var userRoleType = typeof(TUserRole); tblNameAttr = userRoleType.GetCustomAttributes(typeof(TableAttribute), true); noPrefixAttr = userRoleType.GetCustomAttributes(typeof(NoPrefixAttribute), true); UserRoleTableNoPrefix = noPrefixAttr != null && noPrefixAttr.Length > 0; first = tblNameAttr.FirstOrDefault() as TableAttribute; if (first != null) { UserRoleTableName = first; } else { UserRoleTableName = new TableAttribute(userRoleType.Name.Trim().Replace(" ", "")); } if (!UserRoleTableNoPrefix && !string.IsNullOrWhiteSpace(Provider.TablePrefix)) { var schema = UserRoleTableName.Schema; UserRoleTableName = new TableAttribute(Provider.TablePrefix + UserRoleTableName.Name); if (schema != null) { UserRoleTableName.Schema = schema; } } UserRoleType = userRoleType; if (Provider.SupportApplication) { //Check application table var propAppType = RoleHelper.Get(Mapper.RoleColumnType.Application); var appType = propAppType.PropertyType; tblNameAttr = appType.GetCustomAttributes(typeof(TableAttribute), true); noPrefixAttr = appType.GetCustomAttributes(typeof(NoPrefixAttribute), true); ApplicationTableNoPrefix = noPrefixAttr != null && noPrefixAttr.Length > 0; first = tblNameAttr.FirstOrDefault() as TableAttribute; if (first != null) { ApplicationTableName = first; } else { ApplicationTableName = new TableAttribute(appType.Name.Trim().Replace(" ", "")); } if (!ApplicationTableNoPrefix && !string.IsNullOrWhiteSpace(Provider.TablePrefix)) { var schema = ApplicationTableName.Schema; ApplicationTableName = new TableAttribute(Provider.TablePrefix + ApplicationTableName.Name); if (schema != null) { ApplicationTableName.Schema = schema; } } ApplicationType = appType; } }