More in this section
Forums / Developing with Sitefinity / Add Custom field to SitefinityProfile without authentication.

Add Custom field to SitefinityProfile without authentication.

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. Mihail
    Mihail avatar
    0 posts
    Registered:
    15 Feb 2016
    09 Nov 2016
    Link to this post

    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

  2. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    10 Nov 2016 in reply to Mihail
    Link to this post

    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.

  3. Mihail
    Mihail avatar
    0 posts
    Registered:
    15 Feb 2016
    10 Nov 2016
    Link to this post

    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;
    }

3 posts, 0 answered