Add Custom field to SitefinityProfile without authentication.
Hi,
I am using the following page for source http://docs.sitefinity.com/for-developers-create-yes-no-fields I have attached on
Bootstrapper.Initialized += Bootstrapper_Initialized; and my code is running when this event is raised. When the program reach typeContext.SaveChanges(); it throws an exception with this message:
Telerik.Sitefinity.Security.Data.StaticRoot, Telerik.Sitefinity was not granted ChangeConfigurations in Backend for principals with IDs 00000000-0000-0000-0000-000000000000
It means that I should be logged in the system to do the operation. So i need to run this code without authentication (automatically add fields if they not exists), while system is initializing.
Is there any way to archive this ?
I am using Sitefinty 9.0.6000.0
Hi Mihail, You need to login as administrator user in the beginning
User user;
SecurityManager.AuthenticateUser(Membership.Provider.Name,
"admin"
,
true
,
out
user);
Then do your job with fields.
And log out from admin at the end.
Hi, Thanks for reply.
A consider logging in user with administration privileges may cause security issues. I am worried about, if the logout fails for some reason. Next client accessing the site will be logged as admin.
I will try this code later. Just wondering is there a way without login as administrator. Like:
using
(
new
ElevatedModeRegion(newsManager))
newsManager.Provider.SuppressSecurityChecks =
true
;
// add, modify, delete news. Etc... (without authentication)
newsManager.Provider.SuppressSecurityChecks =
false
;