ASPX templates
Version 5.x > ASPX templates > Get Users Activation Date View modes: 
User avatar
Member
Member
Nathan.Falk-metalera - 4/20/2010 9:06:36 AM
   
Get Users Activation Date
I am looking to get the activation date for all cms users in the code behind. Basically this is for a company page that displays "Length of Service" or time since Activation date.

I've figured out how to get the creation date...but I need the activation date.

CMSMembershipProvider membership = new CMSMembershipProvider();
MembershipUserCollection users = new MembershipUserCollection();

int totalRecords = 0;
string tmp = "";

users = membership.GetAllUsers(0, 0, out totalRecords);
foreach (CMSMembershipUser user in users)
{
tmp = user.CreationDate.ToString();
}


I am still new to Kentico. Any help would be appreciated. Thanks.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/21/2010 1:37:01 PM
   
RE:Get Users Activation Date
Hello,

you can use sample code bellow:

DataSet allUsersSettings = CMS.SiteProvider.UserSettingsInfoProvider.GetUserSettings(null, null);
foreach (DataRow drUserSetting in allUsersSettings.Tables[0].Rows)
{
UserSettingsInfo usi = new UserSettingsInfo(drUserSetting);
DateTime userActivationDate = usi.UserActivationDate;
UserInfo user = UserInfoProvider.GetUserInfo(usi.UserSettingsUserID);
}

You can use UserInfo object to get basic user's data like UserName etc.

Best Regards,

Martin Dobsicek

User avatar
Member
Member
nfalk - 4/21/2010 2:19:34 PM
   
RE:Get Users Activation Date
Thanks Martin, this is exactly what I was looking for...

I should have mentioned I could have just by-passed the API and queried the DB directly, but I figured going through the API must have some sort of advantage (other than much cleaner code).

Either way, thanks for the fast response!!