Exemplo n.º 1
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config.IsNull())
                throw new ArgumentNullException("config");

            if (name.IsNullOrWhiteSpace())
                name = "AsliMotorMembershipProvider";

            if (config["description"].IsNullOrWhiteSpace())
            {
                config.Remove("description");
                config.Add("description", "AsliMotor Membership provider");
            }

            base.Initialize(name, config);

            ApplicationName = getConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            pMaxInvalidPasswordAttempts = Convert.ToInt32(getConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            pPasswordAttemptWindow = Convert.ToInt32(getConfigValue(config["passwordAttemptWindow"], "10"));
            pMinRequiredNonAlphanumericCharacters = Convert.ToInt32(getConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"));
            pMinRequiredPasswordLength = Convert.ToInt32(getConfigValue(config["minRequiredPasswordLength"], "7"));
            pPasswordStrengthRegularExpression = Convert.ToString(getConfigValue(config["passwordStrengthRegularExpression"], ""));
            pEnablePasswordReset = Convert.ToBoolean(getConfigValue(config["enablePasswordReset"], "true"));
            pEnablePasswordRetrieval = Convert.ToBoolean(getConfigValue(config["enablePasswordRetrieval"], "true"));
            pRequiresQuestionAndAnswer = Convert.ToBoolean(getConfigValue(config["requiresQuestionAndAnswer"], "false"));
            pRequiresUniqueEmail = Convert.ToBoolean(getConfigValue(config["requiresUniqueEmail"], "true"));

            encryptionKey = HexToByte(getConfigValue(config["encryptionKey"], "ABCDEEA2EFAA00B42A"));

            string password_format = config["passwordFormat"];
            if (password_format.IsNullOrWhiteSpace())
            {
                password_format = "Hashed";
            }

            switch (password_format)
            {
                case "Hashed":
                    pPasswordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    pPasswordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    pPasswordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new Exception(String.Format("PasswordFormatNotSupportedMessage"));
            }
            _reportingRepository = (IReportingRepository) ContextRegistry.GetContext().GetObject("ReportingRepository");
            _queryObjectMapper = (QueryObjectMapper) ContextRegistry.GetContext().GetObject("QueryObjectMapper");
        }
Exemplo n.º 2
0
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config.IsNull())
                throw new ArgumentNullException("config");

            if (String.IsNullOrEmpty(name))
                name = "NHRoleProvider";

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "AsliMotor Role provider");
            }

            base.Initialize(name, config);

            if (String.IsNullOrEmpty(config["applicationName"]) || config["applicationName"].Trim() == "")
            {
                ApplicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
            }
            else
            {
                ApplicationName = config["applicationName"];
            }

            _reportingRepository = ContextRegistry.GetContext().GetObject("ReportingRepository") as IReportingRepository;
            _queryObjectMapper = ContextRegistry.GetContext().GetObject("QueryObjectMapper") as QueryObjectMapper;
        }