Can't create page in code. No access.


I've written a piece of code that creates and publishes a new page. It works fine when I'm logged in with my administrators account but when I try to do this with an account that's not member of any groups it tells me that the required access level is publish. I read in the Getting Started section that you need to use DataFactory.Instance.Save(myPage,EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess); but this doesn't help.

What could be wrong?

Jun 17, 2010 15:47

You should be able to see in the stack trace which function that is throwing the access denied.

Jun 17, 2010 17:34

The code is used to create blog items under a "blog personal page". The exception is thrown when it's trying to create the tags for it. If I create a blog item without adding tags it works just fine but when writing down one or more it crashes due to the lack of publish rights.

Jun 18, 2010 7:52

You need to give the member's user or group publish rights.

Jun 18, 2010 23:08

Frederik, I've given "Everyone" publish rigths and below in that whole branch where the blogs are and it works. Are there any risks to it that I should be aware of?

Jun 21, 2010 11:40

Yes, everyone can post in each others blogs. I would instead give the individual user the proper access rights on only their blog. This can be done when you create their blog programmatically.

Jun 21, 2010 14:19

In a way you could say I've done that. The page id of there blog start page is stored and every time they post the id's are compared to see if they match.

Jun 21, 2010 14:24

I would still use EPiServer's built in access control system for this. That's what it's for :).

Jun 21, 2010 14:26

I'll take a look at it! :) Thanks!

Jun 21, 2010 15:19
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.