AI OnAI Off
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?
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);