I'm migrating users from an older forum system. I'd like to preserve "First Login" and "Last Login" from my old forums. My code looks something like this:
MembershipService := MembershipService.Create('http://localhost/cs/', 'admin', 'asdfadsf') // create user usr := User.Create; usr.Username := UserTableName.AsString; usr.Password := Guid.NewGuid.ToString; usr.PrivateEmail := 'no.email-' + UserTableEmail.AsString usr.JoinDate := Nullable<System.DateTime>.Create(UserTableFirstLogin.AsDateTime); usr := MembershipService.AddUser(usr); // update user (Settings and Status now exist) usr.Settings.EnableEmail := False; usr.Status.LastLogin := UserTableLastLogin.AsDateTime; MembershipService.UpdateUser(usr);
The AddUser and UpdateUser don't return any error messages, and they appear to work with other settings. But JoinDate and LostLogin seem to be ignored. When I edit the newly created user's profile, I see:
The dates I provided were not this.
Any suggestions?
Thanks,Troy
Those dates are not settable via rest, their values are set internally as part of the membership system.
Dan
Dan,
I'm in the same situation too and need to preserve these dates.
Could I first create the users and then update their join and login dates in the backend database?
Thanks,
dr
What I did when I needed to do this was save the dates as extended attributes on the user. Then I used the SQL function here http://code.communityserver.org/?path=CS+Tree\SampleCode\SQL\FetchExtendendAttributeValue.sql and pulled the values back out in an UPDATE query for the user.
Yep, those are just dates in the SQL ASPNet_Membership tables you would have to update them directly in the database.
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com