Aha, posted that before I saw Tims answers. You're quite right Tim. I'm creating new pages that can only be accessed by members of a particular group. Your answer seems more like what I'm after. I'll have a look at that now.
Error 7 'umbraco.cms.businesslogic.web.Access.AddMemberGroupToDocument(int, int)' is obsolete: 'This method is no longer supported. Use the ASP.NET MemberShip methods instead' .
I'll see if I can work out how to do it using the membership methods.
I've discovered another method - AddMemberShipRoleToDocument.
It sounds more like what I'm after, inasmuch as I have a member group called "View Comments" which I'd normally add to a node using Public Access ->Role based access in the admin section if I were doing it manually.
I tried passing it data using this code, but its returned an odd error
Server Error in '/' Application.
Document is not protected!
My code is below, have I missed something obvious or am I barking up the wrong tree by using this method?
Interestingly, although the node has its permissions set correctly, the info doesn't seem to pass across to the admin UI, so when you select "public access" it still takes you through the whole process as if no permissions were set.
This isn't really an issue for me, but it worth noting.
Setting Public Access on a node programatically.
Hi All.
I'm writing nodes to umbraco dynamically and need to set all these nodes to have role based protection, allowing only one group to view them.
I also need to set the login page and error page dynamically as well. I can't see anything on the web about this. Is it possible?
Take a look into the api: umbraco.cms.Permission method MakeNew
hth, Thomas
@Thomas: I think that only applies to Users rather than Members???
@Shaun: I'm assuming you mean you only want site members to access various pages (like an extranet)?
T
Hi Shaun I think you are looking for this API call:
T
Thanks Thomas!
I've had a look at the api info here - http://umbraco.org/apiDocs/html/M_umbraco_BusinessLogic_Permission_MakeNew.htm
But I'm still a bit confused about it.
Can the User parameter just be the one I've used to create the document using Document.MakeNew?
Also, its requesting a CMSNode object, I've created the node using the Document object,
Do I need to create it using a different method? Or is there a way I can read the object back as a a CMSNode?
Finally, whats the permissionkey? I can't seem to find a description of it anywhere?
Sorry to be so dense.
Aha, posted that before I saw Tims answers. You're quite right Tim. I'm creating new pages that can only be accessed by members of a particular group. Your answer seems more like what I'm after. I'll have a look at that now.
I've given it a bash, but it appears its obsolete as a method (I'm using V4)
Error 7 'umbraco.cms.businesslogic.web.Access.AddMemberGroupToDocument(int, int)' is obsolete: 'This method is no longer supported. Use the ASP.NET MemberShip methods instead' .
I'll see if I can work out how to do it using the membership methods.
I've discovered another method - AddMemberShipRoleToDocument.
It sounds more like what I'm after, inasmuch as I have a member group called "View Comments" which I'd normally add to a node using Public Access ->Role based access in the admin section if I were doing it manually.
I tried passing it data using this code, but its returned an odd error
Server Error in '/' Application.
Document is not protected!
My code is below, have I missed something obvious or am I barking up the wrong tree by using this method?
Hi,
Yes you're right with the AddMemberShipRoleToDocument..
No idea why you're getting that error - try adding the role after you have published and Updated the document cache??
T
Hi,
It looks like you may need to call:
first, that way you can set your login page and not-authorised page as well.
If you are going to use Roles then you'll need to set the Simple bool to false.
Then when you have done that you can the roles i.e.
That works brilliantly. Thanks Tim.
Interestingly, although the node has its permissions set correctly, the info doesn't seem to pass across to the admin UI, so when you select "public access" it still takes you through the whole process as if no permissions were set.
This isn't really an issue for me, but it worth noting.
Thanks again for your help Tim.
is working on a reply...