loki
  •  loki
  • 52.4% (Neutral)
  • YAF Forumling Topic Starter
2008-08-11T23:23:11Z
Hi all, have an issue importing users from an old board. I have an export of all the users from the old system but want to import them with a few tweaks into the new. if i didnt have to worry about passwords it would be fine but i cant see how to import all the users and where or how to link there passwords. Also apart from creating the users in the membership and users tables do i have any other links to create?

Here are the columns i have to work with from the old system.

User.USERNAME	User.PASSWORD	User.ID	User.DISPLAY_NAME	User.EMAIL	User.DISPLAY_EMAIL	User.TITLE	User.OCCUPATION	User.INTERESTS	User.LOCATION	User.SIGNATURE	User.PARENT_EMAIL	User.CUSTOM_1	User.CUSTOM_2	User.CUSTOM_3	User.CUSTOM_4	User.IP_AT_REGISTRATION	User.DOB	User.REGISTRATION_DATE	User.LAST_LOGIN_DATETIME	User.LAST_POST_DATETIME	User.HAS_OPTED_OUT_OF_EMAILS	User.ALLOW_PRIVATE_MESSAGES	User.NOTIFY_ON_PRIVATE_MESSAGES	User.CAN_USE_AVATARS	User.IGNORE_AVATARS	User.CAN_PARTICIPATE_IN_POLLS	User.IS_VALIDATED	User.IS_AGE_RESTRICTED_USER	User.IS_ADMINISTRATOR	User.IS_PROFILE_LOCKED	User.IS_PRIVATE_MESSAGING_DISABLED	User.IS_DOB_HIDDEN	User.IS_ACTIVITY_HIDDEN	User.IS_AVATAR_LOCKED	User.IS_BANNED	User.USER_POST_COUNT	User.CUMULATIVE_USER_POST_COUNT	User.DAY_PRUNE	User.PICTURE_URL	User.HOME_PAGE_URL	User.AVATAR_URL


N.
Sponsor
test2005
2008-08-12T02:17:46Z
I wrote a function (although it's in VB) that calls the "old user" table, then creates ASPNETDB accounts based on this information. Here it is...



Public Shared Function Create_New_User(ByVal NewUserName As String, ByVal NewUserPassword As String, ByVal NewUserEmail As String) As String

            Dim status As MembershipCreateStatus

            Try
                Dim newUser As MembershipUser = Membership.CreateUser(NewUserName, NewUserPassword, NewUserEmail, UserQuestion, UserAnswer, True, status)

                If newUser Is Nothing Then
                    Return Create_New_User_GetErrorMessage(status)
                Else
                    If Membership.ValidateUser(newUser.ToString, NewUserPassword) Then

                        Roles.AddUserToRole(newUser.UserName, "T4K_User")

                        Return "successful"

                    End If

                    Return "successful"

                End If
            Catch ex As Exception

                Return "An unknown error occurred."
            End Try
        End Function

        Public Shared Function Create_New_User_GetErrorMessage(ByVal status As MembershipCreateStatus) As String
            Select Case status
                Case MembershipCreateStatus.DuplicateUserName
                    Return "Username already exists. Please enter a different user name."
                Case MembershipCreateStatus.DuplicateEmail
                    Return "A username for that e-mail address already exists. Please enter a different e-mail address or use the password recovery feature."
                Case MembershipCreateStatus.InvalidPassword
                    Return "The password provided is invalid. Please enter a password at least 6 characters long."
                Case MembershipCreateStatus.InvalidEmail
                    Return "The e-mail address provided is invalid. Please check the value and try again."
                Case MembershipCreateStatus.InvalidAnswer
                    Return "The password retrieval answer provided is invalid. Please check the value and try again."
                Case MembershipCreateStatus.InvalidQuestion
                    Return "The password retrieval question provided is invalid. Please check the value and try again."
                Case MembershipCreateStatus.InvalidUserName
                    Return "The user name provided is invalid. Please check the value and try again."
                Case MembershipCreateStatus.ProviderError
                    Return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact " & SystemDefault_Get(6).ToString & " usng the contact page."
                Case MembershipCreateStatus.UserRejected
                    Return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact " & SystemDefault_Get(6).ToString & " usng the contact page."
                Case Else
                    Return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact " & SystemDefault_Get(6).ToString & " usng the contact page."
            End Select
        End Function



So, create a page that calls a dataset from the DB of your "old" usernames. Then call the abouve function. If it returns "successful", move on to the next. If not, Response.Write the old username and error in creating the account to the page. Print it off and deal with them seperate.

HTH

:P

.....the man in black fled across the desert..........and the gunslinger followed.....
jawrat
  •  jawrat
  • 50.6% (Neutral)
  • YAF Forumling
2010-01-14T01:09:39Z
I know this is an old thread, but I just wanted to let you know that this helped me out tremendously. I have a monstrous db of users that I wanted to migrate over to YAF and using your function as the basis, I was able to write something in c# to do the import! Thanks a whole lot! lovin YAF so far!
Users browsing this topic

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved