Beispiel #1
0
        internal static void InitializeRoleProvider(
            SimpleRoleProvider simpleRoles,
            DatabaseConnectionInfo connect,
            string userTableName,
            string userIdColumn,
            string userNameColumn,
            bool createTables,
            SimpleMembershipProviderCasingBehavior casingBehavior)
        {
            if (simpleRoles.InitializeCalled)
            {
                throw new InvalidOperationException(WebDataResources.Security_InitializeAlreadyCalled);
            }

            simpleRoles.CasingBehavior = casingBehavior;
            simpleRoles.ConnectionInfo = connect;
            simpleRoles.UserTableName  = userTableName;
            simpleRoles.UserIdColumn   = userIdColumn;
            simpleRoles.UserNameColumn = userNameColumn;

            if (createTables)
            {
                simpleRoles.CreateTablesIfNeeded();
            }
            simpleRoles.InitializeCalled = true;
        }
Beispiel #2
0
        internal static void InitializeMembershipProvider(
            SimpleMembershipProvider simpleMembership,
            DatabaseConnectionInfo connect,
            string userTableName,
            string userIdColumn,
            string userNameColumn,
            bool createTables,
            SimpleMembershipProviderCasingBehavior casingBehavior)
        {
            if (simpleMembership.InitializeCalled)
            {
                throw new InvalidOperationException(WebDataResources.Security_InitializeAlreadyCalled);
            }

            simpleMembership.CasingBehavior = casingBehavior;
            simpleMembership.ConnectionInfo = connect;
            simpleMembership.UserIdColumn   = userIdColumn;
            simpleMembership.UserNameColumn = userNameColumn;
            simpleMembership.UserTableName  = userTableName;
            if (createTables)
            {
                simpleMembership.CreateTablesIfNeeded();
            }
            else
            {
                // We want to validate the user table if we aren't creating them
                simpleMembership.ValidateUserTable();
            }
            simpleMembership.InitializeCalled = true;
        }
Beispiel #3
0
        public static void InitializeDatabaseConnection(
            string connectionStringName,
            string userTableName,
            string userIdColumn,
            string userNameColumn,
            bool autoCreateTables,
            SimpleMembershipProviderCasingBehavior casingBehavior)
        {
            DatabaseConnectionInfo connect = new DatabaseConnectionInfo();

            connect.ConnectionStringName = connectionStringName;
            InitializeProviders(connect, userTableName, userIdColumn, userNameColumn, autoCreateTables, casingBehavior);
        }
Beispiel #4
0
        private static void InitializeProviders(
            DatabaseConnectionInfo connect,
            string userTableName,
            string userIdColumn,
            string userNameColumn,
            bool autoCreateTables,
            SimpleMembershipProviderCasingBehavior casingBehavior)
        {
            SimpleMembershipProvider simpleMembership = Membership.Provider as SimpleMembershipProvider;

            if (simpleMembership != null)
            {
                InitializeMembershipProvider(simpleMembership, connect, userTableName, userIdColumn, userNameColumn, autoCreateTables, casingBehavior);
            }

            SimpleRoleProvider simpleRoles = Roles.Provider as SimpleRoleProvider;

            if (simpleRoles != null)
            {
                InitializeRoleProvider(simpleRoles, connect, userTableName, userIdColumn, userNameColumn, autoCreateTables, casingBehavior);
            }

            Initialized = true;
        }