Getting current user's name
[C#]
string currentUserName = CMS.CMSHelper.CMSContext.CurrentUser.UserName; |
Checking if user is authenticated
[C#]
bool isAuthenticated = HttpContext.Current.User.Identity.IsAuthenticated; |
Checking if user is member of a role
[C#]
if (CMS.CMSHelper.CMSContext.CurrentUser.IsInRole("CMSEditor", CMS.CMSHelper.CMSContext.CurrentSiteName)) { //the current user is member of the CMSEditor role } |
Checking if user is granted with given permission for a document
[C#]
if (CMS.CMSHelper.CMSContext.CurrentUser.IsAuthorizedPerTreeNode(nodeId, CMS.TreeEngine.NodePermissionsEnum.Read) == CMS.TreeEngine.AuthorizationResultEnum.Allowed) { // the current user is authorized to read the document } |
Checking if user is granted with given permission for a module (resource)
[C#]
if (CMS.CMSHelper.CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Forums", "Modify")) { // the current user is granted with permission "Modify" in the "CMS.Forums" module in the current website } |
Checking if user is granted with given permission for a document type or custom table (class name)
[C#]
if (CMS.CMSHelper.CMSContext.CurrentUser.IsAuthorizedPerClassName("CMS.File", "Delete")) { // the current user is granted with permission "Delete" for all documents of type "CMS.File" in the current website } |
Page url: http://devnet.kentico.com/docs/devguide/index.html?checking_user_permissions.htm