예제 #1
0
        /// <summary>
        /// Initializes the membership system by connecting to a database that contains user information.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="providerName">Name of the provider.</param>
        public static void InitializeDatabaseConnection(string connectionString, string providerName)
        {
            var connect = new DatabaseConnectionInfo {
                ConnectionString = connectionString, ProviderName = providerName
            };

            InitializeProviders(connect);
        }
예제 #2
0
        private static void InitializeProviders(DatabaseConnectionInfo connect)
        {
            var extendedMembership = Membership.Provider as MySqlSimpleMembershipProvider;

            if (extendedMembership != null)
            {
                InitializeMembershipProvider(extendedMembership, connect);
            }

            var extendedRoles = Roles.Provider as MySqlSimpleRoleProvider;

            if (extendedRoles != null)
            {
                InitializeRoleProvider(extendedRoles, connect);
            }

            Initialized = true;
        }
예제 #3
0
 internal static void InitializeRoleProvider(MySqlSimpleRoleProvider extendedRoles, DatabaseConnectionInfo connect)
 {
     if (extendedRoles.InitializeCalled)
     {
         throw new InvalidOperationException(Resources.Security.Security_InitializeAlreadyCalled);
     }
     extendedRoles.ConnectionInfo   = connect;
     extendedRoles.InitializeCalled = true;
 }
예제 #4
0
 internal static void InitializeMembershipProvider(MySqlSimpleMembershipProvider extendedMembership, DatabaseConnectionInfo connect)
 {
     if (extendedMembership.InitializeCalled)
     {
         throw new InvalidOperationException(Resources.Security.Security_InitializeAlreadyCalled);
     }
     extendedMembership.ConnectionInfo = connect;
     // We want to validate the user table if we aren't creating them
     extendedMembership.ValidateTable();
     extendedMembership.InitializeCalled = true;
 }