public static void DeleteDesktopModulePermissionsByUserID(UserInfo objUser)
 {
     provider.DeleteDesktopModulePermissionsByUserID(objUser.UserID);
     Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
     objEventLog.AddLog("UserID", objUser.UserID.ToString(), PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.DESKTOPMODULE_DELETED);
     ClearPermissionCache();
 }
예제 #2
0
 public static string SendMail(UserInfo user, MessageType msgType, PortalSettings settings)
 {
     int toUser = user.UserID;
     string locale = user.Profile.PreferredLocale;
     string subject = "";
     string body = "";
     ArrayList custom = null;
     switch (msgType)
     {
         case MessageType.UserRegistrationAdmin:
             subject = "EMAIL_USER_REGISTRATION_ADMINISTRATOR_SUBJECT";
             body = "EMAIL_USER_REGISTRATION_ADMINISTRATOR_BODY";
             toUser = settings.AdministratorId;
             UserInfo admin = UserController.GetUserById(settings.PortalId, settings.AdministratorId);
             locale = admin.Profile.PreferredLocale;
             break;
         case MessageType.UserRegistrationPrivate:
             subject = "EMAIL_USER_REGISTRATION_PRIVATE_SUBJECT";
             body = "EMAIL_USER_REGISTRATION_PRIVATE_BODY";
             break;
         case MessageType.UserRegistrationPublic:
             subject = "EMAIL_USER_REGISTRATION_PUBLIC_SUBJECT";
             body = "EMAIL_USER_REGISTRATION_PUBLIC_BODY";
             break;
         case MessageType.UserRegistrationVerified:
             subject = "EMAIL_USER_REGISTRATION_VERIFIED_SUBJECT";
             body = "EMAIL_USER_REGISTRATION_VERIFIED_BODY";
             if (HttpContext.Current != null)
             {
                 custom = new ArrayList();
                 custom.Add(HttpContext.Current.Server.UrlEncode(user.Username));
             }
             break;
         case MessageType.PasswordReminder:
             subject = "EMAIL_PASSWORD_REMINDER_SUBJECT";
             body = "EMAIL_PASSWORD_REMINDER_BODY";
             break;
         case MessageType.ProfileUpdated:
             subject = "EMAIL_PROFILE_UPDATED_SUBJECT";
             body = "EMAIL_PROFILE_UPDATED_BODY";
             break;
         case MessageType.UserUpdatedOwnPassword:
             subject = "EMAIL_USER_UPDATED_OWN_PASSWORD_SUBJECT";
             body = "EMAIL_USER_UPDATED_OWN_PASSWORD_BODY";
             break;
     }
     subject = Localization.Localization.GetSystemMessage(locale, settings, subject, user, Localization.Localization.GlobalResourceFile, custom, "", settings.AdministratorId);
     body = Localization.Localization.GetSystemMessage(locale, settings, body, user, Localization.Localization.GlobalResourceFile, custom, "", settings.AdministratorId);
     SendEmail(settings.Email, UserController.GetUserById(settings.PortalId, toUser).Email, subject, body);
     return "";
 }
예제 #3
0
 public static DateTime CurrentTimeForUser(UserInfo User)
 {
     if (User == null || User.UserID == -1 || User.Profile.TimeZone == Null.NullInteger)
     {
         int intOffset = 0;
         PortalSettings objSettings = PortalController.GetCurrentPortalSettings();
         if (objSettings != null)
         {
             intOffset = objSettings.TimeZoneOffset;
         }
         else
         {
             PortalInfo objPCtr = new PortalController().GetPortal(User.PortalID);
             intOffset = objPCtr.TimeZoneOffset;
         }
         return DateTime.UtcNow.AddMinutes(intOffset);
     }
     else
     {
         return DateTime.UtcNow.AddMinutes(User.Profile.TimeZone);
     }
 }
예제 #4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSuperUser gets the superuser from the Install Template
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="xmlTemplate">The install Templae</param>
        ///	<param name="writeFeedback">a flag to determine whether to output feedback</param>
        /// <history>
        /// [cnurse]	02/16/2007	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static UserInfo GetSuperUser(XmlDocument xmlTemplate, bool writeFeedback)
        {
            XmlNode node = xmlTemplate.SelectSingleNode("//dotnetnuke/superuser");
            UserInfo objSuperUserInfo = null;
            if ((node != null))
            {
                if (writeFeedback)
                {
                    HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Configuring SuperUser:<br>");
                }

                //Parse the SuperUsers nodes
                string strFirstName = XmlUtils.GetNodeValue(node.CreateNavigator(), "firstname");
                string strLastName = XmlUtils.GetNodeValue(node.CreateNavigator(), "lastname");
                string strUserName = XmlUtils.GetNodeValue(node.CreateNavigator(), "username");
                string strPassword = XmlUtils.GetNodeValue(node.CreateNavigator(), "password");
                string strEmail = XmlUtils.GetNodeValue(node.CreateNavigator(), "email");
                string strLocale = XmlUtils.GetNodeValue(node.CreateNavigator(), "locale");
                int timeZone = XmlUtils.GetNodeValueInt(node, "timezone");

                objSuperUserInfo = new UserInfo();
                objSuperUserInfo.PortalID = -1;
                objSuperUserInfo.FirstName = strFirstName;
                objSuperUserInfo.LastName = strLastName;
                objSuperUserInfo.Username = strUserName;
                objSuperUserInfo.DisplayName = strFirstName + " " + strLastName;
                objSuperUserInfo.Membership.Password = strPassword;
                objSuperUserInfo.Email = strEmail;
                objSuperUserInfo.IsSuperUser = true;
                objSuperUserInfo.Membership.Approved = true;

                objSuperUserInfo.Profile.FirstName = strFirstName;
                objSuperUserInfo.Profile.LastName = strLastName;
                objSuperUserInfo.Profile.PreferredLocale = strLocale;
                objSuperUserInfo.Profile.TimeZone = timeZone;
            }
            return objSuperUserInfo;
        }
 public static void DeleteModulePermissionsByUser(UserInfo objUser)
 {
     provider.DeleteModulePermissionsByUser(objUser);
     DataCache.ClearModulePermissionsCachesByPortal(objUser.PortalID);
 }
 public static string ResetPassword(UserInfo user, string passwordAnswer)
 {
     if (MembershipProviderConfig.PasswordResetEnabled)
     {
         user.Membership.Password = memberProvider.ResetPassword(user, passwordAnswer);
     }
     else
     {
         throw new ConfigurationErrorsException("Password Reset is not enabled");
     }
     return user.Membership.Password;
 }
 public abstract bool ChangePasswordQuestionAndAnswer(UserInfo user, string password, string passwordQuestion, string passwordAnswer);
 public static UserCreateStatus CreateUser(ref UserInfo objUser)
 {
     UserCreateStatus createStatus = UserCreateStatus.AddUser;
     createStatus = memberProvider.CreateUser(ref objUser);
     if (createStatus == UserCreateStatus.Success)
     {
         Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
         objEventLog.AddLog(objUser, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED);
         DataCache.ClearPortalCache(objUser.PortalID, false);
         if (!objUser.IsSuperUser)
         {
             RoleController objRoles = new RoleController();
             RoleInfo objRole;
             ArrayList arrRoles = objRoles.GetPortalRoles(objUser.PortalID);
             int i;
             for (i = 0; i <= arrRoles.Count - 1; i++)
             {
                 objRole = (RoleInfo)arrRoles[i];
                 if (objRole.AutoAssignment == true)
                 {
                     objRoles.AddUserRole(objUser.PortalID, objUser.UserID, objRole.RoleID, Null.NullDate, Null.NullDate);
                 }
             }
         }
     }
     return createStatus;
 }
 public static UserInfo FillUserInfo(int portalId, IDataReader dr, bool closeDataReader)
 {
     UserInfo objUserInfo = null;
     try
     {
         bool bContinue = true;
         if (closeDataReader)
         {
             bContinue = false;
             if (dr.Read())
             {
                 if (string.Equals(dr.GetName(0), "UserID", StringComparison.InvariantCultureIgnoreCase))
                 {
                     bContinue = true;
                 }
             }
         }
         if (bContinue)
         {
             objUserInfo = new UserInfo();
             objUserInfo.PortalID = portalId;
             objUserInfo.IsSuperUser = Null.SetNullBoolean(dr["IsSuperUser"]);
             objUserInfo.IsDeleted = Null.SetNullBoolean(dr["IsDeleted"]);
             objUserInfo.UserID = Null.SetNullInteger(dr["UserID"]);
             objUserInfo.FirstName = Null.SetNullString(dr["FirstName"]);
             objUserInfo.LastName = Null.SetNullString(dr["LastName"]);
             objUserInfo.RefreshRoles = Null.SetNullBoolean(dr["RefreshRoles"]);
             objUserInfo.DisplayName = Null.SetNullString(dr["DisplayName"]);
             objUserInfo.AffiliateID = Null.SetNullInteger(Null.SetNull(dr["AffiliateID"], objUserInfo.AffiliateID));
             objUserInfo.Username = Null.SetNullString(dr["Username"]);
             GetUserMembership(objUserInfo);
             objUserInfo.Email = Null.SetNullString(dr["Email"]);
             objUserInfo.Membership.UpdatePassword = Null.SetNullBoolean(dr["UpdatePassword"]);
             if (!objUserInfo.IsSuperUser)
             {
                 objUserInfo.Membership.Approved = Null.SetNullBoolean(dr["Authorised"]);
             }
         }
     }
     finally
     {
         CBO.CloseDataReader(dr, closeDataReader);
     }
     return objUserInfo;
 }
 public abstract void UpdateUser(UserInfo user);
 public abstract bool IsUserOnline(UserInfo user);
 public abstract string ResetPassword(UserInfo user, string passwordAnswer);
 public abstract bool UnLockUser(UserInfo user);
 public abstract void GetUserMembership(ref UserInfo user);
 public abstract bool DeleteUser(UserInfo user);
 public abstract UserCreateStatus CreateUser(ref UserInfo user);
예제 #17
0
 public static bool ChangePassword(UserInfo user, string oldPassword, string newPassword)
 {
     bool retValue = Null.NullBoolean;
     if (ValidatePassword(newPassword))
     {
         retValue = memberProvider.ChangePassword(user, oldPassword, newPassword);
         user.Membership.UpdatePassword = false;
         UpdateUser(user.PortalID, user);
     }
     else
     {
         throw new Exception("Invalid Password");
     }
     return retValue;
 }
예제 #18
0
 public UserMembership(UserInfo user)
 {
     _User = user;
 }
예제 #19
0
 public static bool ChangePasswordQuestionAndAnswer(UserInfo user, string password, string passwordQuestion, string passwordAnswer)
 {
     EventLogController objEventLog = new EventLogController();
     objEventLog.AddLog(user, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", CommonLibrary.Services.Log.EventLog.EventLogController.EventLogType.USER_UPDATED);
     return memberProvider.ChangePasswordQuestionAndAnswer(user, password, passwordQuestion, passwordAnswer);
 }
예제 #20
0
 public UserMembership()
 {
     _User = new UserInfo();
 }
예제 #21
0
 public static bool DeleteUser(ref UserInfo objUser, bool notify, bool deleteAdmin)
 {
     bool CanDelete = true;
     IDataReader dr = null;
     try
     {
         dr = DataProvider.Instance().GetPortal(objUser.PortalID, PortalController.GetActivePortalLanguage(objUser.PortalID));
         if (dr.Read())
         {
             if (objUser.UserID == Convert.ToInt32(dr["AdministratorId"]))
             {
                 CanDelete = deleteAdmin;
             }
         }
         if (CanDelete)
         {
             FolderPermissionController.DeleteFolderPermissionsByUser(objUser);
             ModulePermissionController.DeleteModulePermissionsByUser(objUser);
             TabPermissionController.DeleteTabPermissionsByUser(objUser);
             CanDelete = memberProvider.DeleteUser(objUser);
         }
         if (CanDelete)
         {
             PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
             Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
             objEventLog.AddLog("Username", objUser.Username, _portalSettings, objUser.UserID, Services.Log.EventLog.EventLogController.EventLogType.USER_DELETED);
             if (notify && !objUser.IsSuperUser)
             {
                 Message _message = new Message();
                 _message.FromUserID = _portalSettings.AdministratorId;
                 _message.ToUserID = _portalSettings.AdministratorId;
                 _message.Subject = Localization.GetSystemMessage(objUser.Profile.PreferredLocale, _portalSettings, "EMAIL_USER_UNREGISTER_SUBJECT", objUser, Localization.GlobalResourceFile, null, "", _portalSettings.AdministratorId);
                 _message.Body = Localization.GetSystemMessage(objUser.Profile.PreferredLocale, _portalSettings, "EMAIL_USER_UNREGISTER_BODY", objUser, Localization.GlobalResourceFile, null, "", _portalSettings.AdministratorId);
                 _message.Status = MessageStatusType.Unread;
                 //_messagingController.SaveMessage(_message);
                 Services.Mail.Mail.SendEmail(_portalSettings.Email, _portalSettings.Email, _message.Subject, _message.Body);
             }
             DataCache.ClearPortalCache(objUser.PortalID, false);
             DataCache.ClearUserCache(objUser.PortalID, objUser.Username);
         }
     }
     catch (Exception Exc)
     {
         Exceptions.LogException(Exc);
         CanDelete = false;
     }
     finally
     {
         CBO.CloseDataReader(dr, true);
     }
     return CanDelete;
 }
예제 #22
0
 public static void UpdateUser(int portalId, UserInfo objUser)
 {
     UpdateUser(portalId, objUser, true);
 }
예제 #23
0
 public static void GetUserMembership(UserInfo objUser)
 {
     memberProvider.GetUserMembership(ref objUser);
 }
예제 #24
0
 public static void UserLogin(int portalId, UserInfo user, string PortalName, string IP, bool CreatePersistentCookie)
 {
     if (user.IsSuperUser)
     {
         AddEventLog(portalId, user.Username, user.UserID, PortalName, IP, UserLoginStatus.LOGIN_SUPERUSER);
     }
     else
     {
         AddEventLog(portalId, user.Username, user.UserID, PortalName, IP, UserLoginStatus.LOGIN_SUCCESS);
     }
     user.LastIPAddress = IP;
     UserController.UpdateUser(portalId, user);
     FormsAuthentication.SetAuthCookie(user.Username, CreatePersistentCookie);
     int PersistentCookieTimeout = Config.GetPersistentCookieTimeout();
     if (CreatePersistentCookie == true)
     {
         FormsAuthenticationTicket AuthenticationTicket = new FormsAuthenticationTicket(user.Username, true, PersistentCookieTimeout);
         string EncryptedAuthTicket = FormsAuthentication.Encrypt(AuthenticationTicket);
         HttpCookie AuthCookie = new HttpCookie(FormsAuthentication.FormsCookieName, EncryptedAuthTicket);
         AuthCookie.Expires = AuthenticationTicket.Expiration;
         AuthCookie.Domain = FormsAuthentication.CookieDomain;
         AuthCookie.Path = FormsAuthentication.FormsCookiePath;
         HttpContext.Current.Response.Cookies.Set(AuthCookie);
     }
 }
예제 #25
0
 public static bool UnLockUser(UserInfo user)
 {
     bool retValue = false;
     retValue = memberProvider.UnLockUser(user);
     DataCache.ClearUserCache(user.PortalID, user.Username);
     return retValue;
 }
 public abstract bool ChangePassword(UserInfo user, string oldPassword, string newPassword);
예제 #27
0
 /// <summary>
 /// updates a user
 /// </summary>
 /// <param name="portalId">the portalid of the user</param>
 /// <param name="objUser">the user object</param>
 /// <param name="loggedAction">whether or not the update calls the eventlog - the eventlogtype must still be enabled for logging to occur</param>
 /// <remarks></remarks>
 public static void UpdateUser(int portalId, UserInfo objUser, bool loggedAction)
 {
     //Update the User
     memberProvider.UpdateUser(objUser);
     if (loggedAction)
     {
         Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
         objEventLog.AddLog(objUser, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.USER_UPDATED);
     }
     DataCache.ClearUserCache(portalId, objUser.Username);
 }
예제 #28
0
        public TokenReplace(Scope AccessLevel, string Language, PortalSettings PortalSettings, UserInfo User) :
            this(AccessLevel, Language, PortalSettings, User, Null.NullInteger)
        {

        }
예제 #29
0
 public static UserValidStatus ValidateUser(UserInfo objUser, int portalId, bool ignoreExpiring)
 {
     UserValidStatus validStatus = UserValidStatus.VALID;
     if (objUser.Membership.UpdatePassword)
     {
         validStatus = UserValidStatus.UPDATEPASSWORD;
     }
     else if (PasswordConfig.PasswordExpiry > 0)
     {
         DateTime expiryDate = objUser.Membership.LastPasswordChangeDate.AddDays(PasswordConfig.PasswordExpiry);
         if (expiryDate < DateTime.Now)
         {
             validStatus = UserValidStatus.PASSWORDEXPIRED;
         }
         else if (expiryDate < DateTime.Now.AddDays(PasswordConfig.PasswordExpiryReminder) && (!ignoreExpiring))
         {
             validStatus = UserValidStatus.PASSWORDEXPIRING;
         }
     }
     if (validStatus == UserValidStatus.VALID)
     {
         bool validProfile = Convert.ToBoolean(UserModuleBase.GetSetting(portalId, "Security_RequireValidProfileAtLogin"));
         if (validProfile && (!ProfileController.ValidateProfile(portalId, objUser.Profile)))
         {
             validStatus = UserValidStatus.UPDATEPROFILE;
         }
     }
     return validStatus;
 }
예제 #30
0
 public TokenReplace(Scope AccessLevel, string Language, PortalSettings PortalSettings, UserInfo User, int ModuleID)
 {
     this.CurrentAccessLevel = AccessLevel;
     if (AccessLevel != Scope.NoSettings)
     {
         if (PortalSettings == null)
         {
             if (HttpContext.Current != null)
                 this.PortalSettings = PortalController.GetCurrentPortalSettings();
         }
         else
         {
             this.PortalSettings = PortalSettings;
         }
         if (User == null)
         {
             if (HttpContext.Current != null)
             {
                 this.User = (UserInfo)HttpContext.Current.Items["UserInfo"];
             }
             else
             {
                 this.User = new UserInfo();
             }
             this.AccessingUser = this.User;
         }
         else
         {
             this.User = User;
             if (HttpContext.Current != null)
             {
                 this.AccessingUser = (UserInfo)HttpContext.Current.Items["UserInfo"];
             }
             else
             {
                 this.AccessingUser = new UserInfo();
             }
         }
         if (string.IsNullOrEmpty(Language))
         {
             this.Language = new Localization.Localization().CurrentCulture;
         }
         else
         {
             this.Language = Language;
         }
         if (ModuleID != Null.NullInteger)
         {
             this.ModuleId = ModuleID;
         }
     }
     PropertySource["date"] = new DateTimePropertyAccess();
     PropertySource["datetime"] = new DateTimePropertyAccess();
     PropertySource["ticks"] = new TicksPropertyAccess();
     PropertySource["culture"] = new CulturePropertyAccess();
 }