Adding Editors and Owners to BlogEngine.NET blogs in Sueetie

The following is a copy of a new Sueetie Wiki page that shows Gummy Bear administrators how to add editors and owners to site blogs. Still at a formative phase of Sueetie evolution, creating blogs and their users remains a manual process. That will change, of course, but for the present documents like this one will outline the manual process as well as provide the specs for future automation. In other words, all that follows will be replaced by the click of a button, and hopefully soon.

Process Overview

BlogEngine.NET supports two types of users with permissions to create posts: Administrators and Editors. Administrators have full range while editors are somewhat limited in what they can do on a blog. BlogEngine.NET is configured to use ASPNET Membership and Roles so that it can be integrated with Sueetie Membership. Like other applications in Sueetie, BlogEngine.NET extends ASPNET Membership with additional user data. The simple user data model of BlogEngine.NET is shown below.


As you can see, there’s not much to it, so the process of giving user "testguy2" permissions to post to the site will be pretty simple.

Let’s cover the data logic first. The tables in order shown are be_users, be_userRoles and be_roles. New Sueetie users are entered in be_users when they register. Roles in be_roles are populated by the site setup script. New roles to support additional blogs will be added to this table as well. The roles in be_roles match Sueetie site ASPNET Roles and work hand-in-hand with BlogEngine.NET blog permissions. Members in the "BlogAdministrator" role have ownership permissions for all blogs on a Sueetie Community Site. Any additional roles–"SiteBlogEditor" as shown here–are blog-specific. We’ll see how to assign users to blog-specific roles in a bit.

Making Testguy2 a Blog Administrator

Now let’s make testguy2 a site-wide Blog Administrator by adding him to the BlogAdministrator Role in the Sueetie Control Panel. That is shown on this screenshot. Now we will return to the SQL tables where we have a single but important task to perform: add testguy2 to the be_userRoles table. We obtain the BlogEngine.NET UserID for testguy2 and the RoleID for the BlogAdministrator role. Our sql command would be

insert into be_userRoles (userid, roleid) values (14,1)

"14" is the userID for testguy2, "1" the roleID for the BlogAdministrator role.

That’s it.

Making Testguy2 a Blog Editor

There will be times when you create blogs in a Sueetie Community and wish to provide authorship to select members but not give them full administrative permissions. This role assignment is currently ASPNET Role-based, a combination of ASPNET and BlogEngine.NET role assignment logic. To scale Sueetie sites to support hundreds or more blogs, using ASPNET Roles is something we will want to avoid. But for the moment we will describe assigning blog editor status using ASPNET Roles.

We’ll use the main blog of a Sueetie Community Site and make Testguy2 a Blog Editor. We’ll start by adding Testguy2 to the SiteBlogEditor role in the Control Panel. Next we will add testguy2 to the be_userRoles SQL table, but instead of using "1" for the roleID of the BlogAdministrator role, we’ll use "2" for the SiteBlogEditor role.

insert into be_userRoles (userid, roleid) values (14,2)

Gummy Bear supports a SiteBlogEditor role out of the box. The initial design of Gummy Bear also hard-codes "SiteBlogEditor" in the following site blog files:

  1. /blog/admin/web.config
  2. /blog/admin/pages/web.config
  3. /blog/admin/extension manager/web.config
  4. /blog/themes/[theme]/site.master.cs

We will want to re-architect that to use an app.config property at the very least, or a non-ASPNET Roles approach as I mentioned earlier. The good news that adding both a site-wide blog administrator or a specific blog editor is nearly identical.

Add a User Profile in BlogEngine.NET

One final step is to add the user’s profile in BlogEngine.NET (for both Blog Administrator and Blog Editor roles.) This avoids encountering a runtime error immediately after a post is entered by the new user. The Sueetie Follow User function at the bottom of the post looks for the author’s BlogEngine.NET Display Name. User profiles are stored as .XML files in /[blog]/app_data/profiles and will not exist until added in BlogEngine.NET Administration. Here’s a screenshot of the runtime error. (Or if HttpCompression is enabled in /[blog]/app_data/settings.xml, a screen full of gobbledygook.)

Use the BlogEngine.NET "Profiles" tab to add a profile for your Testguy2 user and you’ll be good to go.


Areas on the shortlist for change in future releases

  1. As I mentioned before, we want to get away from using ASPNET Roles for supporting Blog Editor roles. I really don’t like the idea of requiring a role for each blog when anticipating 100’s of blogs on a Sueetie Community Site.
  2. A single Editor role is currently supported in the Gummy Bear release of Sueetie, SiteBlogEditor. That rolename is hard-coded in various locations in BlogEngine.NET config files. We want to move to an app.config value per blog or roll this into the non-ASPNET Role approach to the editor role.
  3. While BlogEngine.NET uses user profile information in useful ways not enabled in Gummy Bear, we don’t need to create a user profile simply to support the Sueetie Follow User function. The best approach to a BlogEngine.NET user profile is to create the /[blog]/app_data/profiles/[username].xml programmatically as part of the Blog Editor creation process when it is added to Sueetie Administrative area.

Wrapping up

We will wrap up with two conclusions, 1) adding a user to a Sueetie BlogEngine.NET blog is a simple manual process that will become automated, hopefully soon, and 2) Sueetie and BlogEngine.NET taste great together.

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.