Example #1
0
        //System.Web.Profile.SqlProfileProvider
        #endregion
        public user CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out string status)
        {
            log.Info("Create new User: "******" in Application " + _App.AppName);
            IuserService UserSrv  = new userService(SessionFactoryConfigPath);
            user         TempUser = UserSrv.GetByName(username);

            if (TempUser != null)
            {
                status = "DuplicateUserName"; return(null);
            }
            TempUser                  = new user();
            TempUser.username         = username;
            TempUser.password         = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            TempUser.PasswordSalt     = "MD5";
            TempUser.PasswordFormat   = (int)PasswordFormat;
            TempUser.email            = email;
            TempUser.PasswordQuestion = passwordQuestion;
            TempUser.PasswordAnswer   = passwordAnswer;
            TempUser.IsApproved       = isApproved;
            TempUser.ApplicationList  = new List <Applications>();
            TempUser.ApplicationList.Add(_App);
            try
            {
                TempUser = UserSrv.CreateNew(TempUser);
                UserSrv.CommitChanges();
                status = "Success";
                return(TempUser);
            }
            catch (Exception ex)
            {
                log.Error("CreateUser Error", ex);
                status = "ProviderError";
                return(null);
            }
        }