Migrating Users from the UmbracoMembershipProvider - Help Needed
I have a client site which used to be a mixed application and Umbraco 4.7 site.
Since inception, the content element of the site has become increasingly isolated from the app side of things and the site is moving further and further toward a fully JavaScript & AJAX based infrastructure with most elements running on only a few pages.
The issue that we have is that all of the login and user data is currently stored in the Umbraco database and for both reporting and future service needs (the site will eventually have apps consuming its services) we need to relocate the user data over to the main application database.
Can anyone tell me how I go about this? I was hoping to just script the transfer of the data over and rewrite some of the code, but it's all tied in with Membership and Role providers (never a favourite technology of mine at the best of times).
Is there a way to convert the data over to a default ASP.Net membership schema implementation or am I better off writing a whole new Membership and role provider and transferring the data myself?
Is there a specific area of the Umbraco code I could look at that might help me?
I'm looking for any help I can here really - preservation of the users and passwords is paramount
There wasn't a quick solution to this - I wrote a set of SQL scripts to extract the data from the Umbraco tables that I needed and then I took a copy of the providers and rewrite the methods to use the new data stores and my new logging system.
The data migration was a bit like this...
USERS - cmsMember (pretty straightforward)
ROLES - Complex - I had to do a translation, here's some of the script...
I hope this helps a bit. Obviously you'd want to adjust the input tables to match your desired storage structure.
The Providers can be found in the Umbraco code and you can rewrite from those or rewrite from scratch - I deleted an awful lot and the end result was the same, I just found that the existing Umbraco code gave me some guidance.
Just for additional refrence, where the script says {DBU_NAME} my deployment script injects the name of the Umbraco database, as the data was being transferred across two databases.
Yep - I just migrated the data in the password field from cmsMember if I remember correctly - Because I kept the config the same and started with the Umbraco provider code as my starting point I had no problems on that side of things. It took me about 3 days I think to do the whole job. As long as your provider code and config for the hashing algorithm remains the same you should be sweet.
Migrating Users from the UmbracoMembershipProvider - Help Needed
I have a client site which used to be a mixed application and Umbraco 4.7 site.
Since inception, the content element of the site has become increasingly isolated from the app side of things and the site is moving further and further toward a fully JavaScript & AJAX based infrastructure with most elements running on only a few pages.
The issue that we have is that all of the login and user data is currently stored in the Umbraco database and for both reporting and future service needs (the site will eventually have apps consuming its services) we need to relocate the user data over to the main application database.
Can anyone tell me how I go about this? I was hoping to just script the transfer of the data over and rewrite some of the code, but it's all tied in with Membership and Role providers (never a favourite technology of mine at the best of times).
I'm looking for any help I can here really - preservation of the users and passwords is paramount
Hi Keith, I'm basically in the same scenario. How did you end up doing this?
Regards,
Amhed-
There wasn't a quick solution to this - I wrote a set of SQL scripts to extract the data from the Umbraco tables that I needed and then I took a copy of the providers and rewrite the methods to use the new data stores and my new logging system.
The data migration was a bit like this...
USERS - cmsMember (pretty straightforward)
ROLES - Complex - I had to do a translation, here's some of the script...
PRINTN'Create user roles...'
SETIDENTITY_INSERT[dbo].[Roles]ON
INSERTINTO[dbo].[Roles]([Id],[Name])VALUES (1,'Registered')
INSERTINTO[dbo].[Roles]([Id],[Name])VALUES (2,'Basic')
INSERTINTO[dbo].[Roles]([Id],[Name])VALUES (3,'Premium')
SETIDENTITY_INSERT[dbo].[Roles]OFF
PRINTN'Create temporary translation tables...'
CREATETABLE#RoleTranslator
(
[Id] INT,
[OldRoleName]NVARCHAR(100),
[NewRoleName]NVARCHAR(100)
)
CREATETABLE#RoleData
(
[UserName]NVARCHAR(1000),
[RoleId]INT
)
PRINTN'Populating translation tables...'
INSERTINTO#RoleTranslator(Id,OldRoleName,NewRoleName)VALUES (1,'Registered','Registered')
INSERTINTO#RoleTranslator(Id,OldRoleName,NewRoleName)VALUES (2,'Basic','Basic')
INSERTINTO#RoleTranslator(Id,OldRoleName,NewRoleName)VALUES (2,'Customer','Basic')
INSERTINTO#RoleTranslator(Id,OldRoleName,NewRoleName)VALUES (3,'Premium','Premium')
INSERTINTO#RoleTranslator(Id,OldRoleName,NewRoleName)VALUES (3,'SuperPremium','Premium')
INSERTINTO#RoleTranslator(Id,OldRoleName,NewRoleName)VALUES (3,'Admin','Premium')
PRINTN'Migrating User Role data...'
INSERTINTO#RoleData(UserName,RoleId)
SELECTDISTINCTM.LoginName,R.Id
FROM[{DBU_NAME}].[dbo].cmsMember2MemberGroupM2MG
INNERJOIN[{DBU_NAME}].[dbo].umbracoNodeN
ONN.id=M2MG.MemberGroup
INNERJOIN[{DBU_NAME}].[dbo].cmsMemberM
ONM.nodeId=M2Mg.Member
INNERJOIN#RoleTranslatorR
ONR.[OldRoleName]COLLATEDATABASE_DEFAULT=N.[text]COLLATEDATABASE_DEFAULT
INSERTINTO[dbo].[MemberRoles]([MemberId],[RoleId])
SELECTSPM.Id,RD.RoleIdFROM#RoleDataRD
INNERJOINMembersSPM
ONSPM.UserNameCOLLATEDATABASE_DEFAULT=RD.UserNameCOLLATEDATABASE_DEFAULT
PRINTN'Deleting temporary tables...'
DROPTABLE#RoleTranslator
DROPTABLE#RoleData
PROFILE DATA - Again I had to do a translation of sorts...
PRINTN'Create temporary translation tables...'
CREATETABLE#ProfileTempData
(
[LoweredUserName]NVARCHAR(1000),
[Alias]NVARCHAR(250),
[DataInt]INT,
[DataText]NVARCHAR(MAX),
[DataDate]DATETIME
)
PRINTN'Populating translation tables...'
INSERTINTO#ProfileTempData(LoweredUserName,Alias,DataInt,DataText,DataDate)
SELECTLOWER(M.LoginName),PT.Alias,PD.dataInt,CONVERT(nvarchar(MAX),PD.dataNvarchar),PD.dataDate
FROM[{DBU_NAME}].[dbo].cmsPropertyDataPD
INNERJOIN[{DBU_NAME}].[dbo].cmsPropertyTypePT
ONPT.id=PD.propertytypeid
INNERJOIN[{DBU_NAME}].[dbo].cmsMemberM
ONM.nodeId=PD.contentNodeId
WHEREPT.AliasIN('datePlanExpires','customerFirstName','customerLastName','guid','isApproved')
ORDERBYPT.Alias,M.LoginName
PRINTN'Migrating User Role data...'
INSERTINTO[dbo].[ProfileData]([LoweredUserName],[Key],[Value])
SELECTLoweredUserName,'DatePlanExpires',CONVERT(nvarchar(MAX),DataDate, 103)
FROM#ProfileTempData
WHEREAlias='datePlanExpires'
UNION
SELECTLoweredUserName,'FirstName',DataText
FROM#ProfileTempData
WHEREAlias='customerFirstName'
UNION
SELECTLoweredUserName,'LastName',DataText
FROM#ProfileTempData
WHEREAlias='customerLastName'
UNION
SELECTLoweredUserName,'Guid',DataText
FROM#ProfileTempData
WHEREAlias='guid'
UNION
SELECTLoweredUserName,'IsApproved',CONVERT(nvarchar(MAX),DataInt)
FROM#ProfileTempData
WHEREAlias='isApproved'
PRINTN'Deleting temporary tables...'
DROPTABLE#ProfileTempData
I hope this helps a bit. Obviously you'd want to adjust the input tables to match your desired storage structure.
The Providers can be found in the Umbraco code and you can rewrite from those or rewrite from scratch - I deleted an awful lot and the end result was the same, I just found that the existing Umbraco code gave me some guidance.
Just for additional refrence, where the script says {DBU_NAME} my deployment script injects the name of the Umbraco database, as the data was being transferred across two databases.
Great! thanks for the feedback!
Were you able to migrate the users with their existing password hashes and configure the new provider to hash the same way?
Yep - I just migrated the data in the password field from cmsMember if I remember correctly - Because I kept the config the same and started with the Umbraco provider code as my starting point I had no problems on that side of things. It took me about 3 days I think to do the whole job. As long as your provider code and config for the hashing algorithm remains the same you should be sweet.
is working on a reply...