Create Event Permissions
I have created a new user and a new role. The user is assigned to this role and the role has been given all permissions under Events -> General:
View event
Create event
Modify event
Delete event
Change event owner
Change event permissions
Whenever I attempt to create an event using the fluent API, I get the following error:
You are not authorized to 'Create 0' ('General').
The code to create an event using the fluent API works correctly when using an admin user, but not when using this user. I would assume the role would only need permission to "Create event", but this is not the case. What permissions do I need to modify to allow this user to successfully create an event through the API?
Thanks.
Hi Geoff,
Can you share the code of your widget so we can have a look at it locally and provide you with helpful solution.
Regards,
Victor Velev
the Telerik team
Thank you for looking into this, Victor. Here is the code in my widget that creates the event and submits it to the simple workflow. Again, this code functions under admin users, but not under my new user/role.
private
void
CreateNewEvent()
Guid eventID = Guid.Empty;
App.WorkWith().Event().CreateNew().Do(calEvent =>
eventID = calEvent.Id;
// Name
calEvent.Title = txtEventName.Text;
calEvent.Description = txtDescription.Text;
/* assign additional properties... etc... */
)
.SaveChanges();
if
(eventID != Guid.Empty)
SubmitEventToWorkflow(eventID);
private
void
SubmitEventToWorkflow(Guid eventID)
var eventItem = App.WorkWith().Event(eventID).Get();
var masterId = eventItem.OriginalContentId;
EventsManager.GetManager().RecompileItemUrls<Event>(eventItem);
if
(eventItem.Status == ContentLifecycleStatus.Master)
EventsManager.GetManager().CheckOut(eventItem);
masterId = eventItem.Id;
EventsManager.GetManager().SaveChanges();
var contextBag =
new
Dictionary<
string
,
string
>();
contextBag.Add(
"ContentType"
, eventItem.GetType().FullName);
WorkflowManager.MessageWorkflow(
masterId,
eventItem.GetType(),
EventsManager.GetDefaultProviderName(),
"SendForApproval"
,
false
,
contextBag);
Hi Geoff,
Can you try and test with the following code which should grant all users permissions to create events:
EventsManager manager = EventsManager.GetManager();
manager.BreakPermiossionsInheritance(eventItem);
var roleId = SecurityManager.ApplicationRoles["Everyone"].Id;
Telerik.Sitefinity.Security.Model.Permission permissionForEveryone = eventItem.GetActivePermissions().Where(p => p.PrincipalId == roleId && p.ObjectId == eventItem.Id).FirstOrDefault();
if (permissionForEveryone == null)
permissionForEveryone = manager.CreatePermission(SecurityConstants.Sets.General.Create, eventItem.Id, roleId);
eventItem.Permissions.Add(permissionForEveryone);
permissionForEveryone.GrantActions(true, SecurityConstants.Sets.General.View);
manager.SaveChanges();
Thank you for your help, Victor. From what I can tell, setting the permissions listed in the OP work correctly in Sitefinity 4.1, so upgrading took care of the issue.
Thanks.