REST API - setting a user's JoinDate or LastLogin date?

rated by 0 users
This post has 4 Replies | 4 Followers

Top 150 Contributor
Posts 141
Points 2,040
wolbrink Posted: Fri, Apr 11 2008 11:48 AM

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:

Member since 04-11-2008
Last login 04-11-2008
Last visited 04-11-2008

The dates I provided were not this.

Any suggestions?

Thanks,
Troy

 

  • Filed under:
  • | Post Points: 20
Top 25 Contributor
Posts 1,160
Points 70,020
CS Developers

 Those dates are not settable via rest, their values are set internally as part of the membership system.

Dan

  • | Post Points: 20
Not Ranked
Posts 27
Points 450
dragonar replied on Thu, Aug 14 2008 11:49 AM

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

Top 75 Contributor
Posts 287
Points 4,270
jeffesp replied on Thu, Aug 14 2008 12:13 PM

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.

--
--Jeff (ATGi)
  • | Post Points: 5
Top 25 Contributor
Posts 1,160
Points 70,020
CS Developers

Yep, those are just dates in the SQL ASPNet_Membership tables you would have to update them directly in the database.

Dan

  • | Post Points: 5
Page 1 of 1 (5 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com