---
title: Checking permissions using the API
related:
  - https://docs.kentico.com/k82/managing-users/configuring-permissions.md
  - https://docs.kentico.com/k82/managing-users/user-management.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

### User privilege levels

```csharp

using CMS.Membership;
using CMS.SiteProvider;

private bool CheckPrivilegeLevel()
{
    // Gets the user object
    UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

    if (user != null)
    {
        // Checks whether the user has the Editor privilege level or higher
        if (user.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, SiteContext.CurrentSiteName))
        {
            // Perform an action according to the result
            return true;
        }
    }

    return false;

}

```

### Module permissions

```csharp

using CMS.Membership;
using CMS.SiteProvider;

private bool CheckModulePermissions()
{
    // Gets the user object
    UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

    if (user != null)
    {
        // Checks whether the user has the Read permission for the Content module
        if (UserInfoProvider.IsAuthorizedPerResource("CMS.Content", "Read", SiteContext.CurrentSiteName, user))
        {
            // Perform an action according to the result
            return true;
        }
    }

    return false;

}

```

### Page type or custom table permissions

```csharp

using CMS.Membership;
using CMS.SiteProvider;

private bool CheckPageTypePermissions()
{
    // Gets the user object
    UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

    if (user != null)
    {
        // Checks whether the user has the Read permission for the CMS.MenuItem page type
        if (UserInfoProvider.IsAuthorizedPerClass("CMS.MenuItem", "Read", SiteContext.CurrentSiteName, user))
        {
            // Perform an action according to the result
            return true;
        }
    }

    return false;

}

```

### Permissions for specific pages (ACLs)

```csharp

using CMS.DocumentEngine;
using CMS.Membership;
using CMS.SiteProvider;
using CMS.DataEngine;

private bool CheckPagePermissions()
{
    // Creates a TreeProvider instance
    TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);

    // Gets the Example page
    TreeNode page = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/Example", "en-US");

    if (page != null)
    {
        // Gets the user object
        UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

        if (user != null)
        {
            // Checks whether the user has the Modify permission for the Example page
            if (page.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, user))
            {
                // Perform an action according to the result
                return true;
            }
        }
    }

    return false;

}

```

### Filtering page data according to permissions

```csharp

using CMS.Membership;
using CMS.Base;
using CMS.DocumentEngine;

...

// Gets the user object
UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

// Gets all news items for which the user has Read permissions
using (new CMSActionContext(user))
{
    var news = DocumentHelper.GetDocuments("CMS.News")
        .OnSite("CorporateSite")
        .Path("/News", PathTypeEnum.Children)
        .CheckPermissions();
}

```
