seting user rights for a page programatically

Vote:
 

Hello!

 

I am creating a page programatically. I want to ad user rights for a specific user to a newly created page.

however I get this weird error that EPiServer.Security.SecurityEntity.User does not exist in the current namespace. why?

here is my code:

PageData myPage = EPiServer.DataFactory.Instance.GetDefaultPageData(parent, "Profile");

            myPage.PageName = username;
            myPage.URLSegment = EPiServer.Web.UrlSegment.CreateUrlSegment(myPage);

            myPage.ACL.Add(new AccessControlEntry(username, AccessLevel.FullAccess, EPiServer.Security.SecurityEntity.User));
            myPage.ACL.Save(SecuritySaveType.Replace);

            DataFactory.Instance.Save(myPage, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

#52212
Jul 12, 2011 16:03
Vote:
 

I have solved my initial problem. It was because I used SecturityEntity and not SecurityEntityType instead ( LOL ) ..

And rearenged my code a little bit.

 

my code:

PageData myPage = EPiServer.DataFactory.Instance.GetDefaultPageData(parent, "Profile");

DataFactory.Instance.Save(myPage, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

myPage.ACL.Add(new AccessControlEntry(username, AccessLevel.FullAccess, SecurityEntityType.User));
myPage.ACL.Save();

Now I receive this error from the ACL save method: "Cannot save ACL with no page link set. This could be due to a page provider not properly setting PageLink."

 

any ideas why?

#52244
Jul 13, 2011 11:53
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.