Example #1
0
        public static void CreateJournalEntry(RoleInfo roleInfo, UserInfo createdBy)
        {
            var journalController = JournalController.Instance;
            var journalItem = new JournalItem();
            
            string url = "";
            
            if (roleInfo.Settings.ContainsKey("URL"))
            {
                url = roleInfo.Settings["URL"];
            }

            journalItem.PortalId = roleInfo.PortalID;
            journalItem.ProfileId = createdBy.UserID;
            journalItem.UserId = createdBy.UserID;
            journalItem.Title = roleInfo.RoleName;
            journalItem.ItemData = new ItemData {Url = url};
            journalItem.SocialGroupId = roleInfo.RoleID;
            journalItem.Summary = roleInfo.Description;
            journalItem.Body = null;
            journalItem.JournalTypeId = journalController.GetJournalType("groupcreate").JournalTypeId;
            journalItem.ObjectKey = string.Format("groupcreate:{0}:{1}", roleInfo.RoleID.ToString(CultureInfo.InvariantCulture), createdBy.UserID.ToString(CultureInfo.InvariantCulture));
            
            if (journalController.GetJournalItemByKey(roleInfo.PortalID, journalItem.ObjectKey) != null)
                journalController.DeleteJournalItemByKey(roleInfo.PortalID, journalItem.ObjectKey);
            
            
            journalItem.SecuritySet = string.Empty;
            
            if (roleInfo.IsPublic)
                journalItem.SecuritySet += "E,";
            
            
            journalController.SaveJournalItem(journalItem, -1);
        }
Example #2
0
        internal virtual Notification AddGroupNotification(string notificationTypeName, int tabId, int moduleId, RoleInfo group, UserInfo initiatingUser, IList<RoleInfo> moderators, IList<UserInfo> recipients) {
            var notificationType = NotificationsController.Instance.GetNotificationType(notificationTypeName);
            var tokenReplace = new GroupItemTokenReplace(group);

            var subject = Localization.GetString(notificationTypeName + ".Subject", Constants.SharedResourcesPath);
            subject = tokenReplace.ReplaceGroupItemTokens(subject);

            var body = Localization.GetString(notificationTypeName + ".Body", Constants.SharedResourcesPath);
            
            body = tokenReplace.ReplaceGroupItemTokens(body);
            body = body.Replace("Public.Text", Localization.GetString("Public.Text", Constants.SharedResourcesPath));
            body = body.Replace("Private.Text", Localization.GetString("Private.Text", Constants.SharedResourcesPath));

            bool dismiss = notificationTypeName != Constants.GroupPendingNotification;
            var notification = new Notification
                                   {
                                       NotificationTypeID = notificationType.NotificationTypeId,
                                       Subject = subject,
                                       Body = body,
                                       IncludeDismissAction = dismiss,
                                       SenderUserID = initiatingUser.UserID,
                                       Context = String.Format("{0}:{1}:{2}", tabId, moduleId, group.RoleID)
                                   };
            NotificationsController.Instance.SendNotification(notification, initiatingUser.PortalID, moderators, recipients);

            return notification;
        }
        internal User LoadUser(DotNetNuke.Entities.Users.UserInfo dnnUser)
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
            User           u = new User();

            DotNetNuke.Entities.Users.UserInfo cu = dnnUser;

            u.UserId      = cu.UserID;
            u.UserName    = cu.Username;
            u.IsSuperUser = cu.IsSuperUser;
            u.IsAdmin     = cu.IsInRole(_portalSettings.AdministratorRoleName);
            u.DateCreated = cu.Membership.CreatedDate;
            u.DateUpdated = cu.Membership.LastActivityDate;
            u.FirstName   = cu.FirstName;
            u.LastName    = cu.LastName;
            u.DisplayName = cu.DisplayName;
            u.Email       = cu.Email;
            u.UserRoles   = GetRoleIds(cu, _portalSettings.PortalId); //RolesToString(cu.Roles)


            if (cu.IsSuperUser)
            {
                u.UserRoles += Globals.DefaultAnonRoles + _portalSettings.AdministratorRoleId + ";";
            }
            Social social = new Social();

            u.UserRoles += "|" + cu.UserID + "|" + social.ActiveSocialGroups(cu.UserID, _portalSettings.PortalId) + "|";

            if (!cu.IsSuperUser)
            {
                u.Properties = GetUserProperties(dnnUser);
            }

            return(u);
        }
Example #4
0
        Post IMetaWeblog.GetPost(string postid, string username, string password)
        {
            LocatePortal(Context.Request);
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui.UserID > 0)
            {
                var post = new Post();

                Article a = Article.GetArticle(Convert.ToInt32(postid), _portalId, true, false);

                post.description = a.ArticleText;
                post.title       = a.Name;
                post.postid      = a.ItemId.ToString();
                post.userid      = a.AuthorUserId.ToString();
                post.dateCreated = Convert.ToDateTime(a.StartDate);

                int i = 0;
                foreach (ItemRelationship ir in a.Relationships)
                {
                    var c = new Category {
                        categoryId = ir.ParentItemId.ToString()
                    };
                    Publish.Category pcc = Publish.Category.GetCategory(ir.ParentItemId);
                    c.categoryName     = pcc.Name;
                    post.categories[i] = c.ToString();
                    i++;
                }
                return(post);
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Remove("Id_Usuario");
            Session.Add("Id_Usuario", UserId);

            iduser.Value = UserId.ToString();

            List <PartialUser> Lpu = new List <PartialUser>();

            System.Collections.ArrayList ListaDeUsuarios = DotNetNuke.Entities.Users.UserController.GetUsers(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId);
            //Response.Write(ListaDeUsuarios.Count.ToString());
            for (int i = 0; i < ListaDeUsuarios.Count; i++)
            {
                DotNetNuke.Entities.Users.UserInfo InfoUsuario = ListaDeUsuarios[i] as DotNetNuke.Entities.Users.UserInfo;
                PartialUser PU = new PartialUser();
                PU.id   = InfoUsuario.UserID;
                PU.name = InfoUsuario.FirstName + " " + InfoUsuario.LastName;
                Lpu.Add(PU);
            }
            Session.Add("ListaUsuarios", Lpu);
            try
            {
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }

            if (DateTime.Now.Month > 9 || DateTime.Now.Year > 2019)
            {
                Responder("<p style=\"color:red\">Error en el sistema</p>");
            }
        }
Example #6
0
        //protected void txtEmail_Change(object sender, EventArgs e)
        //{

        //    try
        //    {
        //        int intRecords = 0;

        //        ArrayList u = new ArrayList();

        //        u = UserController.GetUsersByEmail(this.PortalId, txtEmail.Text.ToString(), 0, 1, ref intRecords);


        //        if (u.Count > 0)
        //        {
        //            // Localization.GetString("AlreadyRegisteredAccountMessage", this.LocalResourceFile)
        //            // AlreadyRegisteredAccountMessage.Text
        //            // lblErrorMessage.Text = "Your e-mail address already has a site account. Please login first to proceed.";
        //            lblErrorMessage.Text = Localization.GetString("AlreadyRegisteredAccountMessage", this.LocalResourceFile);
        //            PanelLogin.Visible = true;
        //            //txtUserName.Text = u[7].ToString();
        //            GridView1.Visible = true;
        //            GridView1.DataSource = u;
        //            GridView1.DataBind();
        //            GridView1.Visible = true;


        //            txtUserName.Text = GridView1.Rows[0].Cells[11].Text.ToString();
        //            PanelPassword.Visible = false;



        //        }
        //        else
        //        {

        // //           GridView1.Dispose();
        //   //         GridView1.Visible = false;
        //            PanelLogin.Visible = false;

        //            reqFirstName.ValidationGroup = "NewRegister";
        //            reqLastName.ValidationGroup = "NewRegister";
        //            reqAddress.ValidationGroup = "NewRegister";
        //            reqCity.ValidationGroup = "NewRegister";
        //            reqPhoneNumber.ValidationGroup = "NewRegister";

        //        }

        //        pnlTerms.Visible = false;

        //    }
        //    catch (Exception ex)
        //    {
        //        Exceptions.ProcessModuleLoadException(this, ex);

        //    }



        //}

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //validate username/password combination
            DotNetNuke.Entities.Users.UserInfo             myUser          = new DotNetNuke.Entities.Users.UserInfo();
            DotNetNuke.Security.Membership.UserLoginStatus userLoginStatus = new DotNetNuke.Security.Membership.UserLoginStatus();
            myUser = DotNetNuke.Entities.Users.UserController.ValidateUser(this.PortalId, txtUserName.Text.ToString(), txtLoginPassword.Text.ToString(), "", "", GetIPAddress(), ref userLoginStatus);

            //     Label1.Text += "userLoginStatus: " + userLoginStatus.ToString() + "";

            if (userLoginStatus == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS ||
                userLoginStatus == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER)
            {
                //login the user ...
                DotNetNuke.Entities.Users.UserController.UserLogin(PortalId, myUser, "", "", true);

                string newURL = Globals.NavigateURL("", "", "LoginStatus=Success", "Foreclosure=" + PropertyID.ToString());

                // Response.Redirect(Request.RawUrl,true);
                Response.Redirect(newURL, true);
            }
            else
            {
                //loggedIn = false;
                //loginFailed = true;
                lblErrorMessage.Text = "Login Failed";
            }
        }
 public override bool IsAuthorized(AuthFilterContext context)
 {
     if (SecurityLevel == SecurityAccessLevel.Anonymous)
     {
         return true;
     }
     User = HttpContextSource.Current.Request.IsAuthenticated ? UserController.Instance.GetCurrentUserInfo() : new UserInfo();
     ContextSecurity security = new ContextSecurity(context.ActionContext.Request.FindModuleInfo());
     switch (SecurityLevel)
     {
         case SecurityAccessLevel.Authenticated:
             return User.UserID != -1;
         case SecurityAccessLevel.Host:
             return User.IsSuperUser;
         case SecurityAccessLevel.Admin:
             return security.IsAdmin;
         case SecurityAccessLevel.Edit:
             return security.CanEdit;
         case SecurityAccessLevel.View:
             return security.CanView;
         case SecurityAccessLevel.Pilot:
             return security.IsPilot;
         case SecurityAccessLevel.Verifier:
             return security.IsVerifier;
     }
     return false;
 }
Example #8
0
    protected void BT_Valider_Click(object sender, EventArgs e)
    {
        string pass1 = TXT_Pass1.Text;
        string pass2 = TXT_Pass2.Text;

        TXT_Resultat.Text = "";
        if (pass1 != pass2)
        {
            TXT_Resultat.Text = "Le mot de passe doit être saisi 2 fois de manière identique";
            return;
        }
        if (pass1.Length < 8)
        {
            TXT_Resultat.Text = "Le mot de passe doit contenir au moins 8 caractères";
            return;
        }
        if (Regex.IsMatch(pass1, @"^[a-zA-Z]+$"))
        {
            TXT_Resultat.Text = "Le mot de passe doit contenir au moins 1 chiffre";
            return;
        }

        string UserName = HttpContext.Current.User.Identity.Name;

        DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, UserName);
        DotNetNuke.Security.Membership.MembershipProvider membershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();

        string oldPassword = DotNetNuke.Entities.Users.UserController.GetPassword(ref userInfo, userInfo.Membership.PasswordAnswer);

        if (DotNetNuke.Entities.Users.UserController.ChangePassword(userInfo, oldPassword, pass1))
        {
            P1.Visible = false;
            P2.Visible = true;
        }
    }
 public static int AddSpeaker(int portalId, int conferenceId, int userId, string email, string firstName, string lastName, string displayName, string company, int updatingUserId)
 {
     var user = UserController.Instance.GetUserById(portalId, userId);
     if (user == null)
     {
         user = UserController.GetUserByEmail(portalId, email);
         if (user == null)
         {
             user = new UserInfo() { PortalID = portalId, Username = email, Email = email, FirstName = firstName, LastName = lastName, DisplayName = displayName };
             user.Membership.Password = UserController.GeneratePassword();
             user.Membership.Approved = true;
             user.Membership.UpdatePassword = true;
             var res = UserController.CreateUser(ref user);
             if (res != DotNetNuke.Security.Membership.UserCreateStatus.Success)
             {
                 throw new System.Exception(res.ToString());
             }
         }
     }
     var speaker = SpeakerRepository.Instance.GetSpeaker(conferenceId, user.UserID);
     if (speaker == null)
     {
         var s = new Models.Speakers.SpeakerBase() { ConferenceId = conferenceId, UserId = user.UserID, Company = company };
         SpeakerRepository.Instance.AddSpeaker(s, updatingUserId);
     }
     DnnRoleController.CheckSpeaker(portalId, conferenceId, user.UserID);
     return user.UserID;
 }
        public UserCreateStatus CreateNewUser(string firstName, string lastName, string emailAddress, int portalId)
        {
            var ctlPortal = new PortalController();
            var portalSettings = ctlPortal.GetPortals().Cast<PortalInfo>().FirstOrDefault(p => p.PortalID == portalId);

            var user = new UserInfo()
            {
                FirstName = firstName,
                LastName = lastName,
                Email = emailAddress,
                Username = emailAddress,
                DisplayName = string.Concat(firstName, " ", lastName),
                PortalID = portalId
            };

            user.Profile.PreferredLocale = portalSettings.DefaultLanguage;
            user.Profile.FirstName = firstName;
            user.Profile.LastName = lastName;

            user.Membership.Approved = true;
            user.Membership.Password = PasswordGenerator.GeneratePassword();
            user.Membership.UpdatePassword = true;

            var status = UserController.CreateUser(ref user);

            User = user;

            return status;
        }
Example #11
0
        CategoryInfo[] IMetaWeblog.GetCategories(string blogid, string username, string password)
        {
            LocatePortal(Context.Request);
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui != null)
            {
                var categoryInfos = new List <CategoryInfo>();

                DataTable dt = Publish.Category.GetCategoriesByPortalId(PortalId);
                foreach (DataRow dr in dt.Rows)
                {
                    var ci = new CategoryInfo
                    {
                        title       = dr["Name"].ToString(),
                        categoryid  = dr["ItemId"].ToString(),
                        description = dr["Description"].ToString(),
                        htmlUrl     =
                            Utility.GetItemLinkUrl((int)dr["ItemId"], PortalId, (int)dr["DisplayTabId"],
                                                   (int)dr["ModuleId"]),
                        rssUrl =
                            ModuleBase.GetRssLinkUrl(dr["ItemId"].ToString(), 25, ItemType.Article.GetId(),
                                                     PortalId, string.Empty)
                    };
                    categoryInfos.Add(ci);
                }

                return(categoryInfos.ToArray());
            }

            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
        public void TicksPropertyAcccess_GetProperty_Returns_Correct_String(string propertyName)
        {
            //Arrange
            var ticksPropertyAccess = new TicksPropertyAccess();
            var accessingUser = new UserInfo();

            long expected = DateTime.MinValue.Ticks;
            switch (propertyName)
            {
                case "now":
                    expected = DateTime.Now.Ticks;
                    break;
                case "today":
                    expected = DateTime.Today.Ticks;
                    break;
                case "ticksperday":
                    expected = TimeSpan.TicksPerDay;
                    break;
            }

            //Act
            bool propertyNotFound = false;
            string propertyValue = ticksPropertyAccess.GetProperty(propertyName, "", CultureInfo.InvariantCulture,
                                                                   accessingUser, Scope.DefaultSettings, ref propertyNotFound);

            //Assert
            Assert.AreEqual(expected.ToString(CultureInfo.InvariantCulture), propertyValue);
        }
Example #13
0
        // REMOVED AS WE'RE NOT USING THIS
        // bool IMetaWeblog.SetPostCategories(string postid, string username, string password, MTCategory[] cat)
        // {

        // for (int i = 0; i < cat.Length; i++)
        // {
        // MTCategory mcat;
        // mcat = cat[i];
        // Item iv = Item.GetItem(Convert.ToInt32(postid), _portalId, ItemType.Article.GetId(), false);
        // Tag t = Tag.GetTag(mcat.categoryName, _portalId);

        // //if this item tag relationship already existed for another versionID don't increment the count;
        // if (!ItemTag.CheckItemTag(iv.ItemId, Convert.ToInt32(t.TagId)))
        // {
        // t.TotalItems++;
        // t.Save();
        // }

        // //it.ItemVersionId = i.ItemVersionId;
        // //ad the itemtag relationship
        // ItemTag.AddItemTag(iv.ItemVersionId, Convert.ToInt32(t.TagId));
        // }

        // throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        // }

        ///<summary>
        /// Authenticate user
        /// </summary>
        /// <param name="username">UserName</param>
        /// <param name="password">Password</param>
        private DotNetNuke.Entities.Users.UserInfo Authenticate(string username, string password)
        {
            // Check user credentials using form authentication

            // Check the portal alias to verify where the request is coming from and set portalid
            UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;

            DotNetNuke.Entities.Users.UserInfo objUser = UserController.ValidateUser(PortalId, username, password, string.Empty, string.Empty, string.Empty, ref loginStatus);

            if (loginStatus == UserLoginStatus.LOGIN_FAILURE || loginStatus == UserLoginStatus.LOGIN_USERLOCKEDOUT ||
                loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
            {
                throw new InvalidCredentialException(Localization.GetString("FailedAuthentication.Text", this.LocalResourceFile));
            }

            // Check for the author/admin roles in Publish
            var hostController = HostController.Instance;

            if (!objUser.IsInRole(hostController.GetString(Utility.PublishAuthorRole + PortalId)) &&
                !objUser.IsInRole(hostController.GetString(Utility.PublishAdminRole + PortalId)))
            {
                throw new InvalidCredentialException(Localization.GetString("FailedAuthentication.Text", this.LocalResourceFile));
            }

            return(objUser);
        }
Example #14
0
        CategoryInfo[] IMetaWeblog.GetCategories(string blogid, string username, string password)
        {
            return(LogExceptions(() =>
            {
                this.LocatePortal(this.Context.Request);
                DotNetNuke.Entities.Users.UserInfo ui = this.Authenticate(username, password);
                if (ui != null)
                {
                    var categoryInfos = new List <CategoryInfo>();

                    DataTable dt = Publish.Category.GetCategoriesByPortalId(PortalId);
                    foreach (DataRow dr in dt.Rows)
                    {
                        var ci = new CategoryInfo
                        {
                            title = dr["Name"].ToString(),
                            categoryid = dr["ItemId"].ToString(),
                            description = dr["Description"].ToString(),
                            htmlUrl = UrlGenerator.GetItemLinkUrl((int)dr["ItemId"], Globals.GetPortalSettings(), (dr["DisplayTabId"] as int?) ?? Null.NullInteger, (int)dr["ModuleId"]),
                            rssUrl = ModuleBase.GetRssLinkUrl(dr["ItemId"].ToString(), 25, Null.NullInteger, PortalId, string.Empty)
                        };
                        categoryInfos.Add(ci);
                    }

                    return categoryInfos.ToArray();
                }

                throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", this.LocalResourceFile));
            }));
        }
Example #15
0
        /// <param name="moduleId"></param>
        /// <param name="tabId"></param>
        /// <param name="permissionKey">You can use the constants, but for modules there are only
        /// those two</param>
        /// <returns></returns>
        public static bool canUserAccessModule(UserInfo user, int portalId, int tabId, ModuleInfo moduleInfo, string permissionKey)
        {
            var retVal = false;
            string permissionsString = null;
            if (moduleInfo.InheritViewPermissions)
            {
                var tabPermissionController = new TabPermissionController();
                var tabPermissionCollection =
                    tabPermissionController.GetTabPermissionsCollectionByTabID(tabId, portalId);
                permissionsString = tabPermissionController.GetTabPermissions(tabPermissionCollection, permissionKey);
            }
            else
            {
                var modulePermissionController = new ModulePermissionController();
                var permissionCollection =
                    modulePermissionController.GetModulePermissionsCollectionByModuleID(moduleInfo.ModuleID, tabId);
                permissionsString = modulePermissionController.GetModulePermissions(permissionCollection, permissionKey);
            }

            char[] splitter = { ';' };
            var roles = permissionsString.Split(splitter);
            foreach (var role in roles)
            {
                if (role.Length > 0)
                {
                    if (user != null && user.IsInRole(role))
                        retVal = true;
                    else if (user == null && role.ToLower().Equals("all users"))
                        retVal = true;
                }
                
            }
            return retVal;
        }
 private void UpdateTimeZoneInfo(UserInfo user, ProfilePropertyDefinitionCollection properties)
 {
     ProfilePropertyDefinition newTimeZone = properties["PreferredTimeZone"];
     ProfilePropertyDefinition oldTimeZone = properties["TimeZone"];
     if (newTimeZone != null && oldTimeZone != null)
     {
         //Old timezone is present but new is not...we will set that up.
         if (!string.IsNullOrEmpty(oldTimeZone.PropertyValue) && string.IsNullOrEmpty(newTimeZone.PropertyValue))
         {
             int oldOffset;
             int.TryParse(oldTimeZone.PropertyValue, out oldOffset);
             TimeZoneInfo timeZoneInfo = Localization.ConvertLegacyTimeZoneOffsetToTimeZoneInfo(oldOffset);
             newTimeZone.PropertyValue = timeZoneInfo.Id;
             UpdateUserProfile(user);
         }
         //It's also possible that the new value is set but not the old value. We need to make them backwards compatible
         else if (!string.IsNullOrEmpty(newTimeZone.PropertyValue) && string.IsNullOrEmpty(oldTimeZone.PropertyValue))
         {
             TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(newTimeZone.PropertyValue);
             if (timeZoneInfo != null)
             {
                 oldTimeZone.PropertyValue = timeZoneInfo.BaseUtcOffset.TotalMinutes.ToString(CultureInfo.InvariantCulture);
             }
         }
     }
 }
Example #17
0
        BlogInfo[] IMetaWeblog.GetUsersBlogs(string key, string username, string password)
        {
            LocatePortal(Context.Request);
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);

            if (ui.UserID > 0)
            {
                //todo: configure blog info for users
                var infoList = new List <BlogInfo>();
                var bi       = new BlogInfo {
                    blogid = "0"
                };
                var pac = new PortalAliasController();
                foreach (PortalAliasInfo api in PortalAliasController.Instance.GetPortalAliasesByPortalId(PortalId))
                {
                    bi.url = "http://" + api.HTTPAlias;
                    break;
                }

                bi.blogName = ui.Username;

                infoList.Add(bi);

                return(infoList.ToArray());
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
 {
     TimeZoneInfo userTimeZone = AccessingUser.Profile.PreferredTimeZone;
     switch (propertyName.ToLower())
     {
         case "current":
             if (format == string.Empty)
             {
                 format = "D";
             }
             return TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString(format, formatProvider);
         case "now":
             if (format == string.Empty)
             {
                 format = "g";
             }
             return TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString(format, formatProvider);
         case "system":
             if (format == String.Empty)
             {
                 format = "g";
             }
             return DateTime.Now.ToString(format, formatProvider);
         case "utc":
             if (format == String.Empty)
             {
                 format = "g";
             }
             return DateTime.Now.ToUniversalTime().ToString(format, formatProvider);
         default:
             PropertyNotFound = true;
             return string.Empty;
     }
 }
Example #19
0
 public Usuario(DotNetNuke.Entities.Users.UserInfo p_UI)
 {
     name     = p_UI.FirstName;
     lastname = p_UI.LastName;
     userid   = p_UI.UserID;
     Ui       = p_UI;
 }
 public ValueProviderWrapperForPropertyAccess(string name, IPropertyAccess source, UserInfo user, CultureInfo localization)
 {
     Name = name;
     _source = source;
     _user = user;
     _loc = localization;
 }
 public void PortalSecurity_IsInRoles_NonAdmin_In_Deny_Role_Is_False()
 {
     var user = new UserInfo { IsSuperUser = false, UserID = UserId };
     const string roles = "!SomeRoleName";
     var portalSettings = SetupPortalSettings();
     Assert.IsFalse(PortalSecurity.IsInRoles(user, portalSettings, roles));
 }
Example #22
0
        MediaObjectInfo IMetaWeblog.NewMediaObject(string blogid, string username, string password,
                                                   MediaObject mediaObject)
        {
            LocatePortal(Context.Request);

            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui.UserID > 0)
            {
                var objectInfo = new MediaObjectInfo();

                string name  = mediaObject.name; //object name
                var    media = mediaObject.bits; //object body

                //Save media object to filesystem. Split name with '/' to extract filename (Windows Live Writer specific)
                int index = name.LastIndexOf('/');
                Directory.CreateDirectory(Utility.GetThumbnailLibraryMapPath(PortalId).AbsolutePath + name.Substring(0, index));
                FileStream stream = File.Create(Utility.GetThumbnailLibraryMapPath(PortalId).AbsolutePath + name);
                stream.Write(media, 0, media.Length);
                stream.Flush();
                stream.Close();
                stream.Dispose();
                objectInfo.url = Utility.GetThumbnailLibraryPath(PortalId) + name;
                return(objectInfo);
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
Example #23
0
        /// <summary>
        /// cstor
        /// </summary>
        /// <param name="moduleId"></param>
        /// <param name="tabId"></param>
        /// <param name="ipAddress"></param>
        /// <param name="user"></param>
        public FloodControl(int moduleId, int tabId, string ipAddress, UserInfo user)
        {
            this.moduleId = moduleId;
            this.tabId = tabId;
            this.ipAddress = ipAddress;
            this.user = user;

            if (user != null)
            {
                //work out if the userinfo 
                //object has edit permission on this module                
                var moduleInfo = ModuleController.Instance.GetModule(moduleId, tabId, false);
                hasEditAccess = ModulePermissionController
                                    .HasModuleAccess(SecurityAccessLevel.Edit,
                                                        null,
                                                        moduleInfo);

                //load the flood control settings
                var settings = new ShoutBoxModuleSettings(moduleId, tabId);
                floodTimePost = settings.FloodNewPost;
                floodTimeReply = settings.FloodReply;
                floodTimeVote = settings.FloodVoting;
            }

            
        }
Example #24
0
        public HttpResponseMessage Users_SendPasswordLink(int userid)
        {
            int v_Current_Portal_ID = this.ActiveModule.PortalID;

            //Getting Host Settings
            string v_HostSMTPSetting = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("SMTPServer");

            if (String.IsNullOrEmpty(v_HostSMTPSetting))
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "smtp-missing"));
            }


            DotNetNuke.Entities.Users.UserController v_User_Cont = new UserController();
            DotNetNuke.Entities.Users.UserInfo       v_User_Info = v_User_Cont.GetUser(v_Current_Portal_ID, userid);

            if (v_User_Info == null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "no-user"));
            }

            if (MembershipProviderConfig.PasswordRetrievalEnabled || MembershipProviderConfig.PasswordResetEnabled)
            {
                UserController.ResetPasswordToken(v_User_Info);
            }

            DotNetNuke.Services.Mail.Mail.SendMail(v_User_Info, DotNetNuke.Services.Mail.MessageType.PasswordReminder, PortalSettings);

            return(Request.CreateResponse(HttpStatusCode.OK, "ok"));
        }
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound)
 {
     switch (propertyName.ToLowerInvariant())
     {
         case "url":
             return NewUrl(objParent.Language);
         case "flagsrc":
             return "/" + objParent.Language + ".gif";
         case "selected":
             return (objParent.Language == CultureInfo.CurrentCulture.Name).ToString();
         case "label":
             return Localization.GetString("Label", objParent.resourceFile);
         case "i":
             return Globals.ResolveUrl("~/images/Flags");
         case "p":
             return Globals.ResolveUrl(PathUtils.Instance.RemoveTrailingSlash(objPortal.HomeDirectory));
         case "s":
             return Globals.ResolveUrl(PathUtils.Instance.RemoveTrailingSlash(objPortal.ActiveTab.SkinPath));
         case "g":
             return Globals.ResolveUrl("~/portals/" + Globals.glbHostSkinFolder);
         default:
             PropertyNotFound = true;
             return string.Empty;
     }
 }
Example #26
0
        public AssetEditor(App app, string path, UserInfo userInfo, PortalSettings portalSettings, bool global = false)
        {
            _app = app;
            _userInfo = userInfo;
            _portalSettings = portalSettings;

            EditInfo = new AssetEditInfo(_app.AppId, _app.Name, path, global);
        }
Example #27
0
 // <summary>
 /// Kiem tra user hien tai chi co quyen view
 /// </summary>
 /// <param name="pUserInfo">UserInfo</param>
 public static bool checkViewRole(DotNetNuke.Entities.Users.UserInfo pUserInfo)
 {
     if (pUserInfo.IsSuperUser)
     {
         return(false);
     }
     return(pUserInfo.IsInRole(ConfigurationManager.AppSettings["Role_DC"]));
 }
 public GroupViewParser(PortalSettings portalSettings, RoleInfo roleInfo, UserInfo currentUser, string template, int groupViewTabId)
 {
     PortalSettings = portalSettings;
     RoleInfo = roleInfo;
     CurrentUser = currentUser;
     Template = template;
     GroupViewTabId = groupViewTabId;
 }
        public void PortalSecurity_IsInRoles_All_Users_Role_Is_Always_True()
        {
            var user = new UserInfo() { IsSuperUser = false, };
            const string roles = Globals.glbRoleAllUsersName;
            var portalSettings = SetupPortalSettings();

            Assert.IsTrue(PortalSecurity.IsInRoles(user, portalSettings, roles));
        }
 /// <summary>
 /// Get Preloaded Data Property.
 /// </summary>
 /// <param name="propertyName">property name.</param>
 /// <param name="format">format.</param>
 /// <param name="formatProvider">format provider.</param>
 /// <param name="accessingUser">accessing user.</param>
 /// <param name="accessLevel">access level.</param>
 /// <param name="propertyNotFound">Whether found the property value.</param>
 /// <returns></returns>
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
 {
     var contactList = _service.GetContacts(searchTerm, _portalId, pageIndex, pageSize);
     var contacts = contactList
                          .Select(contact => new ContactViewModel(contact))
                          .ToList();
     return "{ results: " + JsonConvert.SerializeObject(contacts) + ", pageCount: " + contactList.TotalCount + "}";
 }
Example #31
0
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
 {
     if (obj == null)
     {
         return string.Empty;
     }
     return GetObjectProperty(obj, propertyName, format, formatProvider, ref PropertyNotFound);
 }
        public void PortalSecurity_IsInRoles_Super_User_Is_Always_True()
        {
            var user = new UserInfo() { IsSuperUser = true, };
            const string roles = "";
            var portalSettings = SetupPortalSettings();

            Assert.IsTrue(PortalSecurity.IsInRoles(user, portalSettings, roles));
        }
Example #33
0
    public string GetPassword(string UserName, string device, string version, string fonction)
    {
        DateTime dt      = DateTime.Now;
        string   comment = "";
        string   code    = "ok";
        //envoyerTest(fonction);
        string retour   = "0";
        string Password = "";

        try
        {
            DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(Globals.GetPortalSettings().PortalId, UserName);
            if (userInfo != null)
            {
                DotNetNuke.Security.Membership.MembershipProvider membershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();

                Password = "" + DotNetNuke.Entities.Users.UserController.GetPassword(ref userInfo, userInfo.Membership.PasswordAnswer);

                if (!string.IsNullOrEmpty(Password))
                {
                    string message = "Récupération de votre mot de passe à partir de l'application mobile du district : www.rotary1730.org<br/>";
                    message += "Votre mot de passe est : <br/>";
                    message += Password;

                    PortalSettings ps = PortalController.GetCurrentPortalSettings();
                    Mail.SendEmail(ps.Email, ps.Email, userInfo.Email, "Récupération de votre mot de passe", message);

                    retour = "1";
                }
            }
        }
        catch (Exception ee)
        {
            code    = "erreur";
            comment = ee.ToString();

            Functions.Error(ee);
            retour = "0";
        }

        string output = JsonConvert.SerializeObject(retour);

        if (retour == "1")
        {
            comment = "Password envoyé à " + UserName;
        }
        else
        {
            if (comment == "")
            {
                comment = "Password NON envoyé à " + UserName;
            }
        }

        DataMapping.InsertLogWS(os, device, version, getIP(), dt, getDuree(dt), fonction, code, comment, UserName);

        return(output);
    }
        private static void AddHtmlNotification(string subject, string body, UserInfo user)
        {
            var notificationType = NotificationsController.Instance.GetNotificationType("HtmlNotification");
            var portalSettings = PortalController.GetCurrentPortalSettings();
            var sender = UserController.GetUserById(portalSettings.PortalId, portalSettings.AdministratorId);

            var notification = new Notification {NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID};
            NotificationsController.Instance.SendNotification(notification, portalSettings.PortalId, null, new List<UserInfo> { user });
        }
Example #35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnitOfWork"/> class.
        /// </summary>
        public UnitOfWork()
        {
            this.mDataContext = DataContext.Instance();

            if (HttpContext.Current != null && HttpContext.Current.User.Identity.IsAuthenticated)
            {
                this.mCurrentUser = UserController.GetCurrentUserInfo();
            }
        }
        public int CreatePortal(string portalName, UserInfo adminUser, string description, string keyWords, string templatePath,
                        string templateFile, string homeDirectory, string portalAlias,
                        string serverPath, string childPath, bool isChildPortal)
        {
            var template = GetPortalTemplate(Path.Combine(templatePath, templateFile), null);

            return CreatePortal(portalName, adminUser, description, keyWords, template, homeDirectory, portalAlias,
                                serverPath, childPath, isChildPortal);
        }
 public void PortalSecurity_IsInRoles_NonAdmin_IsInRole_Is_True()
 {
     var user = new UserInfo { IsSuperUser = false, UserID = UserId };
     var mockRoleProvider = MockComponentProvider.CreateRoleProvider();
     mockRoleProvider.Setup(rp => rp.GetUserRoles(It.Is<UserInfo>(u => u.UserID == UserId), It.IsAny<bool>())).Returns(new List<UserRoleInfo> { new UserRoleInfo() { RoleName = "SomeRoleName", Status = RoleStatus.Approved } });
     const string roles = "SomeRoleName";
     var portalSettings = SetupPortalSettings();
     Assert.IsTrue(PortalSecurity.IsInRoles(user, portalSettings, roles));
 }
Example #38
0
        //, bool global = false)
        public AssetEditor(App app, int templateId, UserInfo userInfo, PortalSettings portalSettings)
        {
            _app = app;
            _userInfo = userInfo;
            _portalSettings = portalSettings;

            var template = _app.TemplateManager.GetTemplate(templateId);
            EditInfo = TemplateAssetsInfo(template);
        }
        public User GetDNNUser(int SiteId, int ModuleId, string userName)
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
            User           u = new User();

            DotNetNuke.Entities.Users.UserInfo dnnUser = DotNetNuke.Entities.Users.UserController.GetUserByName(_portalSettings.PortalId, userName);
            u = LoadUser(dnnUser);
            return(u);
        }
 public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound)
 {
     UserMembership objMembership = objUser.Membership;
     bool UserQueriesHimself = (objUser.UserID == AccessingUser.UserID && objUser.UserID != -1);
     if (CurrentScope < Scope.DefaultSettings || (CurrentScope == Scope.DefaultSettings && !UserQueriesHimself) ||
         ((CurrentScope != Scope.SystemMessages || objUser.IsSuperUser) 
             && (propertyName.ToLower() == "password" || propertyName.ToLower() == "passwordanswer" || propertyName.ToLower() == "passwordquestion")
         ))
     {
         PropertyNotFound = true;
         return PropertyAccess.ContentLocked;
     }
     string OutputFormat = string.Empty;
     if (format == string.Empty)
     {
         OutputFormat = "g";
     }
     switch (propertyName.ToLower())
     {
         case "approved":
             return (PropertyAccess.Boolean2LocalizedYesNo(objMembership.Approved, formatProvider));
         case "createdondate":
             return (objMembership.CreatedDate.ToString(OutputFormat, formatProvider));
         case "isonline":
             return (PropertyAccess.Boolean2LocalizedYesNo(objMembership.IsOnLine, formatProvider));
         case "lastactivitydate":
             return (objMembership.LastActivityDate.ToString(OutputFormat, formatProvider));
         case "lastlockoutdate":
             return (objMembership.LastLockoutDate.ToString(OutputFormat, formatProvider));
         case "lastlogindate":
             return (objMembership.LastLoginDate.ToString(OutputFormat, formatProvider));
         case "lastpasswordchangedate":
             return (objMembership.LastPasswordChangeDate.ToString(OutputFormat, formatProvider));
         case "lockedout":
             return (PropertyAccess.Boolean2LocalizedYesNo(objMembership.LockedOut, formatProvider));
         case "objecthydrated":
             return (PropertyAccess.Boolean2LocalizedYesNo(true, formatProvider));
         case "password":
             return PropertyAccess.FormatString(objMembership.Password, format);
         case "passwordanswer":
             return PropertyAccess.FormatString(objMembership.PasswordAnswer, format);
         case "passwordquestion":
             return PropertyAccess.FormatString(objMembership.PasswordQuestion, format);
         case "passwordresettoken":
             return PropertyAccess.FormatString(Convert.ToString(objUser.PasswordResetToken), format);
         case "passwordresetexpiration":
             return PropertyAccess.FormatString(objUser.PasswordResetExpiration.ToString(formatProvider), format);
         case "updatepassword":
             return (PropertyAccess.Boolean2LocalizedYesNo(objMembership.UpdatePassword, formatProvider));
         case "username":
             return (PropertyAccess.FormatString(objUser.Username, format));
         case "email":
             return (PropertyAccess.FormatString(objUser.Email, format));
     }
     return PropertyAccess.GetObjectProperty(objMembership, propertyName, format, formatProvider, ref PropertyNotFound);
 }
        public Hashtable GetUserProperties(DotNetNuke.Entities.Users.UserInfo dnnUser)
        {
            Hashtable ht = new Hashtable();

            foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition up in dnnUser.Profile.ProfileProperties)
            {
                ht.Add(up.PropertyName, up.PropertyValue);
            }
            return(ht);
        }
        private User GetDNNUser(int SiteId, int ModuleId, int userId)
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
            User           u = new User();

            DotNetNuke.Entities.Users.UserController uc      = new DotNetNuke.Entities.Users.UserController();
            DotNetNuke.Entities.Users.UserInfo       dnnUser = uc.GetUser(_portalSettings.PortalId, userId);
            u = LoadUser(dnnUser);
            return(u);
        }
Example #43
0
 public static Usuario GetUserByUserInfo(DotNetNuke.Entities.Users.UserInfo UI)
 {
     if (UI != null)
     {
         return(new Usuario(UI));
     }
     else
     {
         return(null);
     }
 }
Example #44
0
 public static void CopyUserToPortal(UserInfo user, PortalInfo portal, bool mergeUser, bool deleteUser)
 {
     if (deleteUser)
     {
         MoveUserToPortal(user, portal, mergeUser);
     }
     else
     {
         CopyUserToPortal(user, portal, mergeUser);
     }
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// All properties Constructor.
 /// </summary>
 /// <param name="user">The user being authenticated.</param>
 /// <param name="token">The user token</param>
 /// <param name="status">The login status.</param>
 /// <param name="type">The type of Authentication</param>
 /// -----------------------------------------------------------------------------
 public UserAuthenticatedEventArgs(UserInfo user, string token, UserLoginStatus status, string type)
 {
     Profile = new NameValueCollection();
     Message = String.Empty;
     AutoRegister = false;
     Authenticated = true;
     User = user;
     LoginStatus = status;
     UserToken = token;
     AuthenticationType = type;
     RememberMe = false;
 }
 public override string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound)
 {
     if (propertyName.ToLower() == "hosttitle" || CurrentScope == Scope.Debug)
     {
         return base.GetProperty(propertyName, format, formatProvider, AccessingUser, CurrentScope, ref PropertyNotFound);
     }
     else
     {
         PropertyNotFound = true;
         return PropertyAccess.ContentLocked;
     }
 }
        public void PortalSecurity_IsInRoles_NonAdmin_IsInRole_Is_True()
        {
            var user = new UserInfo { IsSuperUser = false, UserID = UserId };

            var mockRoleController = new Mock<IRoleController>();
            mockRoleController.Setup(rc => rc.GetUserRoles(It.Is<UserInfo>(u => u.UserID == UserId), It.IsAny<bool>())).Returns(new List<UserRoleInfo> { new UserRoleInfo() { RoleName = "SomeRoleName", Status = RoleStatus.Approved } });
            RoleController.SetTestableInstance(mockRoleController.Object);

            const string roles = "SomeRoleName";
            var portalSettings = SetupPortalSettings();
            Assert.IsTrue(PortalSecurity.IsInRoles(user, portalSettings, roles));
        }
Example #48
0
        bool IMetaWeblog.DeletePost(string key, string postid, string username, string password, bool publish)
        {
            LocatePortal(Context.Request);
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui.UserID > 0)
            {
                //Item.DeleteItem(Convert.ToInt32(postid));
                Item.DeleteItem(Convert.ToInt32(postid), _portalId);

                return(true);
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
Example #49
0
 public TokenReplace(int moduleId)
 {
     if (HttpContext.Current != null)
     {
         AccessingUser = (UserInfo) (HttpContext.Current.Items["UserInfo"]);
     }
     else
     {
         AccessingUser = new UserInfo();
     }
     CurrentAccessLevel = Scope.DefaultSettings;
     _moduleId = moduleId;
 }
    static public AP_StaffBroker_Staff CreateStaffMember(int PortalId, DotNetNuke.Entities.Users.UserInfo User1in, DotNetNuke.Entities.Users.UserInfo User2in, short staffTypeIn)
    {
        //Create Married Staff


        DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
        if (rc.GetRoleByName(PortalId, "Staff") == null)
        {
            DotNetNuke.Security.Roles.RoleInfo insert = new DotNetNuke.Security.Roles.RoleInfo();
            insert.Description    = "Staff Members";
            insert.RoleName       = "Staff";
            insert.AutoAssignment = false;
            insert.IsPublic       = false;
            insert.RoleGroupID    = -1;
            insert.PortalID       = PortalId;
            rc.AddRole(insert);
        }

        rc.AddUserRole(PortalId, User1in.UserID, rc.GetRoleByName(PortalId, "Staff").RoleID, DateTime.MaxValue);
        rc.AddUserRole(PortalId, User2in.UserID, rc.GetRoleByName(PortalId, "Staff").RoleID, DateTime.MaxValue);



        StaffBrokerDataContext d = new StaffBrokerDataContext();
        var searchStaff          = from c in d.AP_StaffBroker_Staffs where c.Active && (c.UserId1 == User1in.UserID || c.UserId2 == User1in.UserID || c.UserId1 == User2in.UserID || c.UserId2 == User2in.UserID) select c;

        if (searchStaff.Count() > 0)
        {
            return(searchStaff.First());
        }



        AP_StaffBroker_Staff rtn = new AP_StaffBroker_Staff();

        rtn.UserId1     = User1in.UserID;
        rtn.UserId2     = User2in.UserID;
        rtn.PortalId    = PortalId;
        rtn.Active      = true;
        rtn.DisplayName = User1in.FirstName + " & " + User2in.FirstName + " " + User1in.LastName;

        rtn.StaffTypeId = staffTypeIn;
        rtn.CostCenter  = "";

        d.AP_StaffBroker_Staffs.InsertOnSubmit(rtn);
        d.SubmitChanges();



        return(rtn);
    }
Example #51
0
        public string CreateUser(string Username, bool CreateUserFolder = false)
        {
            UserInfo oUser = new DotNetNuke.Entities.Users.UserInfo();

            oUser.AffiliateID = Null.NullInteger;
            oUser.Email       = "*****@*****.**";
            oUser.FirstName   = "FirstName";
            oUser.IsSuperUser = false;
            // I bet you will not create SuperUsers in bulk ;)

            oUser.LastName    = "LastName";
            oUser.PortalID    = PortalSettings.PortalId;
            oUser.Username    = Username;
            oUser.DisplayName = Username;
            // Usually here FirstName+LastName

            oUser.Membership.Password = "******";
            // please check in web.config requirements for your password (length, letters, etc)
            oUser.Membership.Approved = true;
            oUser.Email    = "*****@*****.**";
            oUser.Username = oUser.Username;
            oUser.Membership.UpdatePassword = false;

            oUser.Profile.Country    = "Netherlands";
            oUser.Profile.Street     = "Street";
            oUser.Profile.City       = "City";
            oUser.Profile.Region     = "Region";
            oUser.Profile.PostalCode = "PostalCode";
            oUser.Profile.Unit       = "Unit";
            oUser.Profile.Telephone  = "Telephone";
            oUser.Profile.FirstName  = oUser.FirstName;
            oUser.Profile.LastName   = oUser.LastName;

            // Actually create the user
            DotNetNuke.Security.Membership.UserCreateStatus objCreateStatus = UserController.CreateUser(ref oUser);
            // everything fine
            if (objCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success)
            {
                if (CreateUserFolder)
                {
                    FolderManager.Instance.GetUserFolder(oUser);
                }

                return("");
            }
            else
            {
                return(objCreateStatus.ToString());
            }
        }
Example #52
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            LogMessage("Welcome", "Welcome");

            DotNetNuke.Entities.Modules.ModuleController objModulesHome = new DotNetNuke.Entities.Modules.ModuleController();
            int.TryParse("" + objModulesHome.GetModuleSettings(ModuleId)["HomeMobile"], out tabidHome);

            string id = "" + Request["id"];
            LogMessage("Param Id", id);

            string pwd = "" + Request["pwd"];
            LogMessage("Param Pwd", pwd);


            DotNetNuke.Security.Membership.UserLoginStatus loginStatus = new DotNetNuke.Security.Membership.UserLoginStatus();
            LogMessage("LoginStatus", loginStatus.ToString());

            if (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(pwd))
            {
                DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.ValidateUser(this.PortalId, id, pwd, "", this.PortalSettings.PortalName, Request.UserHostAddress, ref loginStatus);

                if (userInfo != null)
                {
                    LogMessage("UserInfo", userInfo.UserID.ToString());
                }


                if (userInfo != null && loginStatus == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS)
                {
                    DotNetNuke.Entities.Users.UserController.UserLogin(this.PortalId, userInfo, this.PortalSettings.PortalName, Request.UserHostAddress, true);
                    Response.Redirect(Globals.NavigateURL(tabidHome, ""));   //refresh site
                }
                else
                {
                    //Message d'erreur et ouverture sur le site
                }
            }
            else
            {
                //Message d'erreur et ouverture sur le site
                LogMessage("PB identifiants", "Identifiant VIDE");
            }
        }
        catch (Exception ee)
        {
            AIS.Functions.Error(ee);
        }
    }
Example #53
0
        public void CreatePortal3Users()
        {
            EntitySpaces.Interfaces.esProviderFactory.Factory = new EntitySpaces.LoaderMT.esDataProviderFactory();

            DotNetNuke.Entities.Users.UserInfo objUserInfo = new DotNetNuke.Entities.Users.UserInfo();
            DotNetNuke.Entities.Users.UserInfo objNewUser  = new DotNetNuke.Entities.Users.UserInfo();

            //By default authorise registration to both portals (1 & 3).
            objNewUser.PortalID  = 3;
            objNewUser.FirstName = "Fred";

            objNewUser.LastName    = "Flintstone";
            objNewUser.Email       = "*****@*****.**";
            objNewUser.Username    = "******";
            objNewUser.DisplayName = objNewUser.FirstName + " " + objNewUser.LastName;
            objNewUser.AffiliateID = DotNetNuke.Common.Utilities.Null.NullInteger;

            objNewUser.Membership.Password = "******";
            objNewUser.Membership.Approved = true;
            objNewUser.Membership.Username = "******";

            objNewUser.Profile.InitialiseProfile(0);
            objNewUser.Profile.FirstName = "Fred";
            objNewUser.Profile.LastName  = "Flintstone";
            objNewUser.Profile.Telephone = "";
            objNewUser.Profile.Website   = "";

            objNewUser.Profile.SetProfileProperty("Unit", "");
            objNewUser.Profile.SetProfileProperty("Street", "");
            objNewUser.Profile.SetProfileProperty("City", "");
            objNewUser.Profile.SetProfileProperty("Region", "");
            objNewUser.Profile.SetProfileProperty("PostalCode", "");
            objNewUser.Profile.SetProfileProperty("Country", "");
            objNewUser.Profile.SetProfileProperty("Cell", "");
            objNewUser.Profile.SetProfileProperty("Fax", "");
            objNewUser.Profile.SetProfileProperty("IM", "");
            //objNewUser.Profile.SetProfileProperty("Suffix", dr[4].ToString());

            //Add the User
            UserCreateStatus createStatus;

            createStatus = UserController.CreateUser(ref objNewUser);

            //set roles here

            //DotNetNuke.Security.Roles.RoleController objRoleController = new DotNetNuke.Security.Roles.RoleController();
            ////now add our role that this user will have
            //objRoleController.AddUserRole(0, objNewUser.UserID, 1, DateTime.Now, DateTime.Now.AddYears(100));
        }
Example #54
0
        Post[] IMetaWeblog.GetRecentPosts(string blogid, string username, string password,
                                          int numberOfPosts)
        {
            LocatePortal(Context.Request);
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui.UserID > 0)
            {
                var posts = new List <Post>();

                // TODO: Implement your own logic to get posts and set the posts
                //TODO: get a collection of posts for an author...

                return(posts.ToArray());
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
        private void ddlLocations_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int weatherId           = Int32.Parse(ddlLocations.SelectedValue);
            BTBWeatherFeedInfo info = DataProvider.GetBTBWeatherFeed(weatherId);

            //determine if user persistance is enabled
            //and store the selection
            if (ModuleSettings.AllowUserPersonialisation && HttpContext.Current.User.Identity.IsAuthenticated)
            {
                DotNetNuke.Entities.Users.UserInfo curUser = UserController.GetUserById(PortalId, UserId);

                curUser.Profile.SetProfileProperty(USER_PERSONIALISATION, ddlLocations.SelectedValue);
                UserController.UpdateUser(this.PortalId, curUser);
            }

            DisplayFeed(info);
        }
Example #56
0
        BloggerPost[] IMetaWeblog.GetRecentPosts(string key, string blogid, string username, string password, int numberOfPosts)
        {
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            var bp = new BloggerPost();

            if (ui.UserID > 0)
            {
                var posts = new List <BloggerPost>();

                bp.content     = "test post";
                bp.dateCreated = DateTime.Now;
                bp.postid      = "1";
                bp.userid      = "1";
                // TODO: Implement your own logic to get posts and set the posts

                return(posts.ToArray());
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
Example #57
0
        UserInfo IMetaWeblog.GetUserInfo(string key, string username, string password)
        {
            LocatePortal(Context.Request);
            DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password);
            if (ui.UserID > 0)
            {
                var info = new UserInfo
                {
                    email     = ui.Email,
                    firstname = ui.FirstName,
                    lastname  = ui.LastName,
                    nickname  = ui.DisplayName,
                    userid    = ui.UserID.ToString()
                };

                return(info);
            }
            throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile));
        }
Example #58
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Page_Load runs when the control is loaded
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <history>
 /// </history>
 /// -----------------------------------------------------------------------------
 protected void Page_Load(System.Object sender, System.EventArgs e)
 {
     try
     {
         lErrorText.Text = "";
         if (!Page.IsPostBack && !Page.IsCallback)
         {
             atiStepSelect.Src = ResolveUrl("~/DesktopModules/ATI_Base/resources/images/stepSelect.png");
             if (string.IsNullOrEmpty((string)Settings["LandingPage"]))
             {
                 ShowError("WARNING: No Landing Page set.  Contact Administrator");
             }
             //CATALooK.ProductsDB productDB = new CATALooK.ProductsDB();
             //string product = productDB.GetProductbyProductID(Convert.ToInt32(Settings["ProductId"]), PortalId);
             //if (product == null || product.Equals(string.Empty))
             //{
             //    throw new Exception("No Monthly Membership Product Setup. Contact Administrator");
             //}
             if (Request["r"] != null && !Request["r"].Equals(string.Empty))
             {
                 int rid = Convert.ToInt32(Request["r"]);
                 DotNetNuke.Entities.Users.UserInfo user = DotNetNuke.Entities.Users.UserController.GetUser(PortalId, rid, true, true);
                 if (user != null)
                 {
                     Session["AffiliateId"] = rid;
                     Request.Cookies.Add(new HttpCookie("AffiliateId", Convert.ToString(rid)));
                 }
                 else
                 {
                     // TODO: log this
                     DotNetNuke.Services.Log.EventLog.ExceptionLogController exLogController = new ExceptionLogController();
                     exLogController.AddLog(new Exception("User linked to site with affliate id of a non existant user"), ExceptionLogController.ExceptionLogType.GENERAL_EXCEPTION);
                 }
             }
         }
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
        internal static int GetUserIdByUserName(int PortalId, string UserName)
        {
            try
            {
                DotNetNuke.Entities.Users.UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, UserName);
                if (user != null)
                {
                    return(user.UserID);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(-1);
        }
        /// <summary>
        /// Get user from DNN cache, if it doesn't exist create him
        /// </summary>
        /// <param name="username"></param>
        /// <param name="portalSettings"></param>
        /// <param name="isDiagnosticModeEnabled">Enable that flag to create logs with info about what this method do</param>
        /// <returns></returns>
        public UserInfo User_Create(string username, PortalSettings portalSettings, bool isDiagnosticModeEnabled)
        {
            DotNetNuke.Entities.Users.UserInfo _userInfo = null;

            if (!string.IsNullOrEmpty(username) && portalSettings != null)
            {
                //check if user already exists in DNN
                _userInfo = DotNetNuke.Entities.Users.UserController.GetCachedUser(portalSettings.PortalId, username);

                //user not exists in DNN, so let's create a user
                if (_userInfo == null)
                {
                    //create user
                    _userInfo                        = new UserInfo();
                    _userInfo.Username               = username;
                    _userInfo.PortalID               = portalSettings.PortalId;
                    _userInfo.Membership.Approved    = true;
                    _userInfo.Membership.CreatedDate = DateTime.Now;
                    _userInfo.AffiliateID            = DotNetNuke.Common.Utilities.Null.NullInteger;
                    _userInfo.IsDeleted              = false;
                    _userInfo.Membership.IsDeleted   = false;
                    _userInfo.Membership.Password    = DotNetNuke.Entities.Users.UserController.GeneratePassword(13);
                    DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(ref _userInfo);
                    if (userCreateStatus != DotNetNuke.Security.Membership.UserCreateStatus.Success)
                    {
                        throw new ArgumentException(userCreateStatus.ToString());
                    }
                    if (isDiagnosticModeEnabled)
                    {
                        logger.Debug(string.Format("User '{0}' created in DNN portal", _userInfo.Username));
                    }
                }
                else if (isDiagnosticModeEnabled)
                {
                    logger.Debug(string.Format("User '{0}' found in DNN portal", _userInfo.Username));
                }
            }
            return(_userInfo);
        }