How to check for admin role membership

Topics: ASP.NET 2.0
Jul 30, 2012 at 7:37 PM

Folks,

I used to have a property like this in my BlogEngine v1.6 extensions:

public bool ShowAdminButtons
{
    get
    {
       return Thread.CurrentPrincipal.Identity.IsAuthenticated && 
User.IsInRole(BlogSettings.Instance.AdministratorRole);     } }
but that doesn't work in v2.6 anymore - that AdministratorRole is no longer available.

How do I check whether the current user is Admin or not in the current version?
Coordinator
Jul 30, 2012 at 7:56 PM

This should work:

if(BlogEngine.Core.Security.IsAdministrator) { ... }

Jul 30, 2012 at 9:18 PM

Works like a charm - thanks a lot !