public AspnetApplication CreateOrLoadApplication(string appName)
        {
            // Prepare a place-holder for the application.
            AspnetApplication app = GetApplication(appName);

            // Determine if the application record does not exists in the data store.
            if (null == app)
            {
                try
                {
                    // Create a new application instance.
                    app = new AspnetApplication();
                    app.ApplicationName = appName;
                    app.LoweredApplicationName = appName.ToLowerInvariant();
                    // Update it in the data store.
                    Save(app);
                }
                catch (Exception ex)
                {
                    throw ExceptionUtil.NewProviderException(Resources.App_UnableToCreateOrLoad, ex);
                }
            }

            // Return the resulting application instance.
            return app;
        }
Beispiel #2
0
        public IList<string> GetRoleNames(AspnetApplication application)
        {
            IList<string> results;

            IQuery query = CurrentSession.CreateQuery("select m.RoleName from AspnetRole as m where m.AspnetApplication.ApplicationId = :applicationId");
            query.SetGuid("applicationId", application.ApplicationId);
            results = query.List<string>();
            return results;
        }
 public AspnetMembership GetAspnetMembership(string username, AspnetApplication application)
 {
     AspnetMembership result;
     IQuery query = CurrentSession.CreateQuery("from AspnetMembership as m where m.AspnetApplication.ApplicationId = :appId and m.UserName = :username");
     query.SetParameter("appId", application.ApplicationId);
     query.SetString("username", username);
     result = query.UniqueResult<AspnetMembership>();
     return result;
 }
Beispiel #4
0
 public AspnetUser GetAspnetUser(string username, AspnetApplication application)
 {
     AspnetUser result;
     IQuery query = CurrentSession.CreateQuery("from AspnetUser as aspUser where aspUser.Application.ApplicationId = :appId and aspUser.UserName = :username");
     query.SetParameter("appId", application.ApplicationId);
     query.SetString("username", username);
     result = query.UniqueResult<AspnetUser>();
     return result;
 }
        public AspnetMembership GetMembership(Guid userId, AspnetApplication application)
        {
            AspnetMembership result;

            IQuery query = CurrentSession.CreateQuery("from AspnetMembership as member where member.AspnetApplication.ApplicationId = :appId and member.MembershipId = : userId");
            query.SetParameter("appId", application.ApplicationId);
            query.SetParameter("userId", userId);
             result = query.UniqueResult<AspnetMembership>();
            return result;
        }
 public IList<AspnetMembership> GetMembershipsByAppIdAndUserEmail(AspnetApplication application, string email)
 {
     return _aspnetMembershipDao.GetMembershipsByAppIdAndUserEmail(application, email);
 }
 public IList<AspnetMembership> GetMembershipByAppIdAndUserName(AspnetApplication application, string username)
 {
     return _aspnetMembershipDao.GetMembershipByAppIdAndUserName(application, username);
 }
 public void Update(AspnetApplication application)
 {
     CurrentSession.Update(application);
 }
        public IList<AspnetMembership> GetMembershipByAppIdAndUserName(AspnetApplication application, string username)
        {
            IList<AspnetMembership> results;

            IQuery query = CurrentSession.CreateQuery("from AspnetMembership as member where member.AspnetApplication.ApplicationId = :appId and member.User.UserName = : userName");
            query.SetParameter("appId", application.ApplicationId);
            query.SetString("userName", username);
            results = query.List<AspnetMembership>();
            return results;
        }
 public void RemoveAppUserReferences(AspnetApplication application, string username)
 {
     _aspnetUserDao.RemoveAppUserReferences(application, username);
 }
Beispiel #11
0
 public void RemoveAppUserReferences(AspnetApplication application, string username)
 {
     object[] values = new object[] { application.ApplicationId, username };
     IType[] types = new IType[] { NHibernateUtil.Guid, NHibernateUtil.String };
     CurrentSession.Delete("from AspnetUser as u where where u.Application.ApplicationId = ? and u.UserName = ?", values, types);
 }
Beispiel #12
0
 public int GetUsersOnline(AspnetApplication application, DateTime compareTime)
 {
     IList<AspnetUser> results;
     IQuery query = CurrentSession.CreateQuery("from AspnetUser as aspUser where aspUser.Application.ApplicationId = :appId and aspUser.LastActivityDate > :lastDate");
     query.SetParameter("appId", application.ApplicationId);
     query.SetDateTime("lastDate", compareTime);
     results = query.List<AspnetUser>();
     return results.Count;
 }
 public void UpdateApplication(AspnetApplication application)
 {
     _aspnetApplicationDao.Update(application);
 }
 public void DeleteApplication(AspnetApplication app)
 {
     _aspnetApplicationDao.Delete(app);
 }
 public void Delete(AspnetApplication application)
 {
     CurrentSession.Delete(application);
 }
 public AspnetUser GetAspnetUser(string username, AspnetApplication application)
 {
     return _aspnetUserDao.GetAspnetUser(username, application);
 }
 public int GetUsersOnline(AspnetApplication application, System.DateTime compareTime)
 {
     return _aspnetUserDao.GetUsersOnline(application, compareTime);
 }
 public IList<string> GetRoleNames(AspnetApplication application)
 {
     return _aspnetRoleDao.GetRoleNames(application);
 }
        private void SetConfigurationProperties(NameValueCollection config)
        {
            application =
                _aspnetApplicationService.CreateOrLoadApplication(
                    ConfigurationUtil.GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath));

            maxInvalidPasswordAttempts = Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["maxInvalidPasswordAttemps"], "5"));
            passwordAttemptWindow = Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["passwordAttemptWindow"], "10"));
            minRequiredNonAlphanumericCharacters = Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"));
            minRequiredPasswordLength = Convert.ToInt32(ConfigurationUtil.GetConfigValue(config["minRequiredPasswordLength"], "7"));
            passwordStrengthRegularExpression = Convert.ToString(ConfigurationUtil.GetConfigValue(config["passwordStrengthRegularExpression"], String.Empty));
            enablePasswordReset = Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["enablePasswordReset"], "true"));
            enablePasswordRetrieval = Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["enablePasswordRetrieval"], "true"));
            requiresQuestionAndAnswer = Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
            requiresUniqueEmail = Convert.ToBoolean(ConfigurationUtil.GetConfigValue(config["requiresUniqueEmail"], "true"));
            SetPasswordFormat(ConfigurationUtil.GetConfigValue(config["passwordFormat"], "Hashed"));
            machineKey = GetMachineKeySection();
        }
        /// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific
        /// attributes specified in the configuration for this provider.</param>
        /// <param name="name">The friendly name of the provider.</param>
        /// <exception cref="ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="InvalidOperationException">An attempt is made to call <see cref="Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        /// <exception cref="ArgumentException">The name of the provider has a length of zero.</exception>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Initialize values from Web.config.
            if (null == config)
            {
                throw (new ArgumentNullException("config"));
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "NHibernateRoleProvider";
            }
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "NHibernate Role Provider");
            }

            // Call the base class implementation.
            base.Initialize(name, config);

            if (_aspnetMembershipService == null)
            {
                IApplicationContext context = ContextRegistry.GetContext();
                _aspnetMembershipService = (IAspnetMembershipService)context.GetObject("IAspnetMembershipService");
            }

            if (_aspnetApplicationService == null)
            {
                IApplicationContext context = ContextRegistry.GetContext();
                _aspnetApplicationService = (IAspnetApplicationService)context.GetObject("IAspnetApplicationService");
            }

            if (_aspnetRoleService == null)
            {
                IApplicationContext context = ContextRegistry.GetContext();
                _aspnetRoleService = (IAspnetRoleService)context.GetObject("IAspnetRoleService");
            }

            string appName = ConfigurationUtil.GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            application =
             _aspnetApplicationService.CreateOrLoadApplication(appName);

            if (config["writeExceptionsToEventLog"] != null)
            {
                if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE")
                {
                    pWriteExceptionsToEventLog = true;
                }
            }

            // Load configuration data.
            //application = _applicationService.CreateOrLoadApplication(appName);

            //application =
            //    NHibernateProviderEntityHelper.CreateOrLoadApplication(
            //        ConfigurationUtil.GetConfigValue(config["applicationName"], HostingEnvironment.ApplicationVirtualPath));
        }
        public IList<AspnetMembership> GetMembershipsByAppIdAndUserEmail(AspnetApplication application, string email)
        {
            IList<AspnetMembership> results;

            IQuery query = CurrentSession.CreateQuery("from AspnetMembership as member where member.AspnetApplication.ApplicationId = :appId and member.Email = : email");
            query.SetParameter("appId", application.ApplicationId);
            query.SetString("email", email);
            results = query.List<AspnetMembership>();
            return results;
        }
 public AspnetMembership GetAspnetMembership(string username, AspnetApplication application)
 {
     return _aspnetMembershipDao.GetAspnetMembership(username, application);
 }
 public AspnetMembership GetMembership(Guid guid, AspnetApplication application)
 {
     return _aspnetMembershipDao.GetMembership(guid, application);
 }
 public Guid Save(AspnetApplication application)
 {
     return (Guid)CurrentSession.Save(application);
 }