SaaS CMS has officially launched! Learn more now.

Leif Boström
Jan 11, 2010
  9460
(0 votes)

Keeping track of the EPiServer Community user limit

The license model for EPiServer Community has a restriction on the maximum number of users that can register for a community based website. If the number of registered community users exceeds the license user limit a license error will be thrown.

LicenseError - Max Number Of Users Exceeded

As a website’s community grows additional license upgrades can be made to suit the number of community users. Depending on the initial budget and estimated need for “user licenses” there is a tiered price ladder that permits the Community to grow.

  1. 0 - 10 000 members
  2. up to 30 000 members
  3. up to 60 000 members
  4. up to 100 000 members
  5. up to 200 000 members
  6. up to 500 000 members
  7. up to 700 000 members
  8. up to 1 000 000 members
  9. up to 1 500 000 members
  10. up to 2 000 000 members
  11. up to 3 000 000 members
  12. up to 5 000 000 members

Other options may apply. Always check with your EPiServer Solution Partner for a price list.

 

So how does one know when to upgrade, and on time as well?

A quick way to find out how many users there are is to tap into the database and query the EPiServer Community table, tblEPiServerCommonUser. This simple query returns the number of active users:

SELECT COUNT(*) 
FROM [dbo].[tblEPiServerCommonUser] 
WHERE [blnRemoved] = 1

A more convenient way in the long run though, would be to create a Scheduled Job in EPiServer that automatically sends an e-mail to the customer (or EPiServer partner) with the current number of community users.

Basically it’s only one line of code to find the current number of users:

EPiServer.Community.CommunitySystem.CurrentContext.DefaultSecurity.UserCount

Putting it all together, the Scheduled Job Plugin could look something like this (error handling omitted and strings hard coded for the sake of brevity).

  1: using System.Globalization;
  2: using System.Net.Mail;
  3: using EPiServer.PlugIn;
  4: 
  5: namespace MySite.Common.ScheduledJobs
  6: {
  7:     [ScheduledPlugIn(DisplayName = "EPiServer Community user counter")]
  8:     public class CommunityUserLicenseCounter
  9:     {
 10:         const string EMAIL_SUBJECT = "{0} - Current number of EPiServer Community users";
 11:         const string EMAIL_BODY = "Current number of EPiServer Community users: {0} for site: {1}.";
 12: 
 13:         public static string Execute()
 14:         {
 15:             string body = string.Format(EMAIL_BODY, CurrentUserCount, SiteUrl);
 16:             SendEmailMessage(body);
 17:             return body;
 18:         }
 19: 
 20:         private static string CurrentUserCount
 21:         {
 22:             get
 23:             {
 24:                 int userCount = EPiServer.Community.CommunitySystem.CurrentContext.DefaultSecurity.UserCount;
 25:                 return userCount.ToString("N0", CultureInfo.CreateSpecificCulture("sv-SE"));
 26:             }
 27:         }
 28: 
 29:         private static string SiteUrl
 30:         {
 31:             get { return EPiServer.Configuration.Settings.Instance.SiteUrl.AbsoluteUri; }
 32:         }
 33: 
 34:         private static string SiteDisplayName
 35:         {
 36:             get { return EPiServer.Configuration.Settings.Instance.SiteDisplayName; }
 37:         }
 38: 
 39:         private static void SendEmailMessage(string body)
 40:         {
 41:             string to = "info@mysite.com";
 42:             string from = "info@mysite.com";
 43:             string subject = string.Format(EMAIL_SUBJECT, SiteDisplayName);
 44:             MailMessage message = new MailMessage(from, to, subject, body);
 45:             SmtpClient client = new SmtpClient();
 46:             client.UseDefaultCredentials = true;
 47:             client.Send(message);
 48:         }   
 49:     }
 50: }
 51: 

The result after running the scheduled job looks like this:

ScheduledJob - EPiServer Community User Counter

 

Some final touch up

I nice addition would be to extract the UserLimit from the license file and only notify the website owner when a certain threshold has been reached, e.g. when the current number of users passes 90% of the UserLimit. I’ve yet to find a way of extracting the MaxUsers in the EPiServer.Community.License namespace. Maybe someone can contribute with a solution?

The user limit setting can be found in the EPiServerRelateLicense.config file in the <UserLimit /> section.

 

More information on how to create a custom scheduled job can be found on Ted’s blog.

Jan 11, 2010

Comments

Sep 21, 2010 10:33 AM

Nice post! A small reflection though, in the first case where you just query the database you should use blnRemoved=0 to get the active users.
/ Tom Stenius

Leif Boström
Leif Boström Sep 21, 2010 10:33 AM

Thanks for pointing that out Tom! That would make more sense. :-)

Please login to comment.
Latest blogs
Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024

Optimizely release SaaS CMS

Discover the future of content management with Optimizely SaaS CMS. Enjoy seamless updates, reduced costs, and enhanced flexibility for developers...

Andy Blyth | Jul 17, 2024 | Syndicated blog

A day in the life of an Optimizely Developer - London Meetup 2024

Hello and welcome to another instalment of A Day In The Life Of An Optimizely Developer. Last night (11th July 2024) I was excited to have attended...

Graham Carr | Jul 16, 2024

Creating Custom Actors for Optimizely Forms

Optimizely Forms is a powerful tool for creating web forms for various purposes such as registrations, job applications, surveys, etc. By default,...

Nahid | Jul 16, 2024

Optimizely SaaS CMS Concepts and Terminologies

Whether you're a new user of Optimizely CMS or a veteran who have been through the evolution of it, the SaaS CMS is bringing some new concepts and...

Patrick Lam | Jul 15, 2024