/// <summary> /// Each Umbraco User should have an Umbraco Forms permissions record which holds their overall permissions for Umbraco Forms. /// This preserves existing permissions and adds a 'deny all' permission if there is no record. /// </summary> /// <param name="userId">The user.</param> /// <param name="forEveryone">if set to <c>true</c> overwrite all existing permissions with 'deny all'.</param> public void RemoveManageFormsPermissions(int userId, bool forEveryone) { using (UserSecurityStorage userSecurityStorage = new UserSecurityStorage()) { var userSecurity = userSecurityStorage.GetUserSecurity(userId.ToString()).FirstOrDefault(); var hasSecurityAlready = (userSecurity != null); if (!hasSecurityAlready) { userSecurity = UserSecurity.Create(); userSecurity.User = userId.ToString(); } userSecurity.ManageForms = false; userSecurity.ManageDataSources = false; userSecurity.ManagePreValueSources = false; userSecurity.ManageWorkflows = false; if (!hasSecurityAlready) { userSecurityStorage.InsertUserSecurity(userSecurity); } else if (forEveryone) { userSecurityStorage.UpdateUserSecurity(userSecurity); } } }