zoukankan      html  css  js  c++  java
  • CommunityServer2.1删除anonymous帐号后的解决办法

    今天又不小心将CS上的匿名帐号给删了,没有匿名帐号,没有登录的用户就不能正常访问。记得上次是新建一个用户,然后在后台把anonymous勾上就可以了,正好今天在做用户验证模块的修改,如果匿名帐号不能用,其它帐号根本就无法登录,所以碰到了不小的麻烦。想恢复数据库到某个时间点却老是提示失败,后面只好用google了,搜到了CS社区的这篇文章:
    Deleted Anonymous user. Anyway to fix this....??

    解决方法是这样的:

    Are you running Community Server 2.1?  Did you delete the anonymous user in the Control Panel Membership page and tell it to reassign all posts assigned to the Anonymous user to "anonymous"?

     If all of the above are true, then it would have deleted all of the anonymous user records in the database, but kept all of the posts. The post records would link to the now non-existant anonymous user account so they would not show up or possibly give an error when viewing them.

    Attached is a simple SQL script to recreate the CS anonymous user once it has been deleted in the scenario above. It will do so with the same UserID as the old one, so anonymous posts should be visible and work again.  There are two settings in the script that you need to check to make sure they match your site's settings:  the application name (in aspnet_applications table - in most sites it is "dev" ) and the UserID of the deleted Anonymous user account. In most cases the anonymous userid is 2101, but you can double check this by looking in the cs_posts table and finding the UserId of posts you know are anonymous.

    Hope that helps!

    大概意思就是运行他提供的一段SQL脚本来重新创建匿名帐号,为了保证以前该帐号发的贴的正常,需要将这个新建的帐号的CS_Userid跟删除的一样,另外应用程序名也需要根据实际情况做修改。

    代码如下:

    /***********************************
    Restore CS Anonymous User Script
    --------------------------------
    A script to re-create the CS
    anonymous user with the same UserID
    as previously used so any posts
    assigned to the anon user will
    show back up.
    *********************************
    */

    Declare @UserID uniqueidentifier
    Declare @ApplicationID uniqueidentifier
    Declare @EveryoneRoleID uniqueidentifier
    Declare @SettingsID int
    Declare @ApplicationName nvarchar(256)
    Declare @cs_UserID int

    /***********************************
    Check the two settings below
    to make sure they are correct
    for your CS site!
    *********************************
    */
    Set @cs_UserID = 2101
    Set @ApplicationName = 'dev'
    /*******************************/

    Set @UserID = newid()
    Select top 1 @ApplicationID = ApplicationId FROM aspnet_Applications where ApplicationName = @ApplicationName
    Select top 1 @SettingsID = SettingsID FROM cs_SiteSettings where ApplicationName = @ApplicationName
    Select top 1 @EveryoneRoleID = RoleId FROM aspnet_Roles where LoweredRoleName = 'everyone'


    Print 'Re-Creating Anonymous User'
    INSERT INTO [aspnet_Users] ([UserId], [ApplicationId], [UserName], [LoweredUserName], [MobileAlias], [IsAnonymous], [LastActivityDate])
    VALUES (@UserID, @ApplicationID, 'Anonymous', Lower('Anonymous'), NULL, 1, getdate())

    INSERT INTO [aspnet_Membership] ([ApplicationId],[UserId], [Password], [PasswordFormat], [PasswordSalt], [MobilePIN], [Email], [LoweredEmail], [PasswordQuestion], [PasswordAnswer], [IsApproved], [CreateDate], [LastLoginDate], [LastPasswordChangedDate], [Comment], [FailedPasswordAnswerAttemptWindowStart], [FailedPasswordAnswerAttemptCount], [FailedPasswordAttemptWindowStart], [FailedPasswordAttemptCount], [LastLockoutDate], [IsLockedOut])
    VALUES (@ApplicationID, @UserID, @UserID, 0, N'DVZTktxeMzDtXR7eik7Cdw==', NULL, 'anonymous@localhost.com', NULL, NULL, NULL, 1, getdate(), getdate(), getdate(), NULL, '1753-01-01', 0, '1753-01-01', 0, '1753-01-01', 0)

    SET IDENTITY_INSERT cs_Users ON
    INSERT INTO [cs_Users]([MembershipID], [UserId], [ForceLogin], [UserAccountStatus], [AppUserToken], [LastActivity], [LastAction])
    VALUES(@UserID, @cs_UserID, 0,1, null, getdate(), '')
    SET IDENTITY_INSERT cs_Users OFF

    INSERT INTO [cs_UserProfile]([UserID], [TimeZone], [TotalPosts], [PostSortOrder], [PostRank], [IsAvatarApproved], [ModerationLevel], [EnableThreadTracking], [EnableDisplayUnreadThreadsOnly], [EnableAvatar], [EnableDisplayInMemberList], [EnablePrivateMessages], [EnableOnlineStatus], [EnableHtmlEmail], [MembershipID], [SettingsID], [PropertyNames], [PropertyValues])
    VALUES (@cs_UserID, 0, 0, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 1, 0, @UserID, @SettingsID, NULL, NULL)

    -- add the anonymous user to the everyone role
    INSERT INTO aspnet_UsersInRoles ([UserId], [RoleId]) VALUES( @UserID, @EveryoneRoleID )

    select * from cs_users where UserID = @cs_UserID


  • 相关阅读:
    Android APK瘦身方法小结
    快速了解Android重要机制
    Android 画笔Paint
    android 图片凸出
    金钱转换
    WPF属性与特性的映射(TypeConverter)
    XMAL 中x名称控件的Auttribute
    AtCoder Grand Contest 012 B
    scau 17967 大师姐唱K的固有结界
    Centos7开机自动启动服务和联网
  • 原文地址:https://www.cnblogs.com/flashlm/p/CreateAnonymousUseInCS2_1.html
Copyright © 2011-2022 走看看