Why this script is only working in preview mode - Kentico - kentico

Why below script is only working in preview mode of Kentico CMS
{% Documents["/Page-Resource/Portfolio/Product-Marketo"].GetValue("Description") #%}

Actually had a issue with the macro permissions for document collections. In such case, disable the check by adding the following key to web.config file:
<add key="CMSCheckPermissionsForDocumentCollection" value="false"/>

Another option:
For the document you reference in your macro, go to Properties > Security, add "Public Anonymous User (public)" to the "Users and Roles" box, and check "Read" for their "Access rights". Click OK.

Related

How to dynamically authorize users in MVC inside Application_Start

I am using MVC 5 to build an application. In my web.config I have defined a custom section which I will use to display menu to user. It is something like:
<Menus>
<Menu>
<MainMenu Title="Home"></MainMenu>
<SubMenus>
<SubMenu Title="Page1" PageName="home/index" ADGroup="BusinessUsers">
<SubMenu Title="Page2" PageName="home/index2" ADGroup="ITUsers">
</SubMenus>
</Menu>
<Menu>
<MainMenu Title="About Us"></MainMenu>
<SubMenus>
<SubMenu Title="Another Page1" PageName="about/mypage1" ADGroup="BusinessUsers">
<SubMenu Title="Some Other Page" PageName="about/mypage2" ADGroup="OtherUsers">
</SubMenus>
</Menu>
</Menus>
I am using Windows authentication and everyone will have access via AD groups. By default I have denied access to all users using authorization rule in web.config like below:
<authorization><deny users="*"/></authorization>
Is it possible to define authorization rules based on MENU above in Application_Start at runtime? Something like:
Global.Filters.AuthorizeUser("BusinessUsers", "home/index, about/mypage1");
Global.Filters.AuthorizeUser("ITUsers", "home/index2");
What you're doing here isn't a standard way of defining a menu, so there is no standard way of enforcing authorization on it. You will need to implement it yourself.
Somewhere in your code during a request, you will have to loop through each SubMenu and use HttpContext.Current.User.IsInRole("DOMAIN\\GroupName") to test whether the user is in the appropriate group. I can't give you any further direction than that without seeing more of your code.
I'm sure you have your reasons for putting this in web.config, but what I have done in my own projects is define the menu in a partial view and check the roles right in the view:
#if (HttpContext.Current.User.IsInRole("DOMAIN\\GroupName") {
Some menu item
}
If you're worried about being able to update the menu items without recompiling the whole project, then that's still fine since the cshtml files aren't compiled anyway - you can update it on the fly.

No Code First Migrations When Deploying Via Visual Studio 2013

I've written an API with no azure connection currently. I am now ready to publish this to Azure. In doing so, I assumed, as was the case with many other deployments, there would be an option for code first migrations. The website already exists, so when I log in I select my website in the drop down, but the screen I get looks like the below where the code-first migrations checkbox should be:
How do I correct this so that I can deploy with code-first migrations?
I found the solution to this issue. If this happens, then your publish profile is set to update the database schema, but not to allow code first migrations. I can't speak to why Visual Studio sometimes does this, but to fix it, you'll need to alter the xml file representing that profile. They can be found under the 'Publish Profiles' folder. Most likely, your <PublishDatabaseSettings> element will have an <Object Type="Dbfx...etc."> and possibly and <UpdateFrom> element. Get rid of those and replace the settings with the below.
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="Namespace.Models.YourDBClass" Order="1" Enabled="True">
<Destination Path="your-connection-string-goes-here" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Namespace.Models.YourDBClass, AssamblyName" MigrationConfiguration="Namespace.Migrations.Configuration, Assambly" Origin="Convention" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
Now clean and rebuild for good measure and you should be ready to go. Do note, if you do not delete the other pre-generated elements in the PublishDatabaseSettings element the schema will update on publish and you will likely have an error on your first attempt to hit your API and the migrations occur. In my case, and in most, it will be an 'X already exists' error, as the migrations are attempting to create tables that were already created with the schema update.
I was able to figure out the issue and correct it with the help of this article: http://www.dominicstpierre.com/2012/11/enable-code-first-migrations-check-box.html

Disable ClientSide Validation

in this posting:
How to disable Client-side Validation for an XPage?
Sven demonstrated setting the property to disable the client side validation.
<xp:this.properties>
<xp:parameter name="xsp.client.validation" value="false" />
</xp:this.properties>
I tried this in a test XPage and it works great, I then tried it in my application and I get an error when the Submit button is clicked that my Rich Text Field is undefined. I have a custom control that contains all the input and validation and it is called from the an ext Lib Application Layout Control. I have removed most everything I can from my App Layout but when I do a submit it does the correct validation but also gives the message:
---------------------------
xpWFSDemoInput
---------------------------
An error occurred while updating some of the page.
dijit.byId("view:_id1:_id2:_id3:_id4:callback1:_id145:callback1:_id148:inputRichText1") is undefined
---------------------------
OK
---------------------------
I place my input custom control inside a new Xpage, set the parameter on the Xpage and run it and it works fine, it sees the RichText and processes it correctly. So there would appear to be something in the App Layout that is causing problems.
I will try putting the Ext Lib Applayout into an XPage and see what happens.
Some further info -- I found the problem code which is some client side script that does a periodic time check. No idea why it hates the RTF though.
If you want to disable client-side validation for the application, you can do so in the Xsp Properties in the application. You can also do it in an xsp.properties file on the server. Check out XPages Portable Command Guide for more details on this and all xsp.properties settings

Permissions exception during debug while using Glimpse

I get exceptions during debug when using Glimpse:
The SELECT permission was denied on the object 'XXX', database 'YYY', schema 'dbo'.
Background:
We have an MVC3 web application using Linq2Sql to access the database (the connection string is not in web.config but set programmatically)
The metadata tab is not filled properly in the Glimpse panel
The sql tab is filled properly in the Glimpse panel, both using Glimpse.ADO and FlexLabs.Glimpse.Linq2Sql
Dbo does not (and should not) have access to specified object and database. For database access we set a connection string programmatically that specifies the user
So the problem seems to be that Glimpse is trying to fill the metadata tab in the Glimpse panel by using dbo to access the database - that will not work in our case.
Is there any way to programmatically specify a connection string that Glimpse should use, or can we turn of the metadata tab to avoid this problem. A setting would in our case not be useful as we cannot have the connection string in web.config.
You can disable the metadata tab by adding the following ignore rule to the Glimpse configuration
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<tabs>
<ignoredTypes>
<add type="Glimpse.Mvc.Tab.Metadata, Glimpse.Mvc3" /><!-- or Glimpse.Mvc4 -->
</ignoredTypes>
</tabs>
...
</glimpse>

WSS 3.0 Site Definition breaks when including MasterUrl in onet.xml

I have created a simple site definition for WSS 3.0 which uses a feature, this feature provisions a master page into the masterpage gallery.
This works absolutely fine, and once I've created a site from the definition I can go into the masterpage gallery and view my provisioned file.
If, however, I set the MasterUrl in my Configuration node of onet.xml and then create a new site from it, it fails. After clicking create it redirects me to the new site automatically but presents me with a file not found error. So I type in the url to the settings page and click to view the masterpage gallery which then gives me a file not found error again.
I'm not sure what's going on, but it looks to me like setting the MasterUrl prevents it from creating the correct lists to which the feature can provision the masterpage to. Can anyone shed any light on this matter for me please?
Here is the webtemp*.xml:
<?xml version="1.0" encoding="utf-8"?>
<Templates>
<Template Name="MasterPageTest" ID="10902">
<Configuration ID="0"
Title="MasterPageTest"
Description="Testing master page deployment"
Hidden="FALSE"
ImageUrl="/_layouts/images/stsprev.png"
DisplayCategory="Test"
/>
</Template>
</Templates>
And the onet.xml (with the masterurl attribute removed):
<?xml version="1.0"?>
<Project Title="MasterPageTest" Revision="3" ListDir="$Resources:core,lists_Folder;" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- _locID#Title="camlidonet1" _locComment="{StringCategory=HTX}" -->
<NavBars>
</NavBars>
<ListTemplates>
</ListTemplates>
<DocumentTemplates>
</DocumentTemplates>
<Configurations>
<Configuration ID="0"
Description="Testing master page deployment"
Title="Master Page Test"
Name="MasterPageTest"
>
<!-- MasterUrl="_catalogs/masterpage/MasterPage.master" -->
<Lists>
</Lists>
<Modules>
</Modules>
<SiteFeatures>
</SiteFeatures>
<WebFeatures>
<!-- Masterpage -->
<Feature ID="8175B375-38F5-44E2-950A-9600D5427E17"/>
</WebFeatures>
</Configuration>
</Configurations>
<Modules>
</Modules>
<ServerEmailFooter>$Resources:ServerEmailFooter;</ServerEmailFooter>
</Project>
My first thought was: Why in the onet.xml?
I usually do this using a process called Feature stapling. It is impossible to remove / disable functionality created from a site definition later on (off course you could by hand, or a feature + receiver to remove say a list you don't need for a particular site created from the onet.xml, but you probably get the point).
By using feature stapling, (your / the) site definition stays clean and stays what it is meant to be: a definition of a site, that can be selected during site creation. IMHO, it should be nothing more than an empty container.
Feature Stapling binds features you want activated when a site is created to a (custom) siteTEMPLATE. You can even use this to attach features you want activated on out of the box site definitions as well. For instance, feature stapling is the preferred way of enabling features in the "MySite" and "My Site Host" definitions. The original sitedefintion remains untouched, but your features are activated too!
Now to actually answer your question: The masterpage is probably not available yet when the site definition is used, the onet.xml is processed before any features are activated.
If your site is a publishing site (meaning the publishing related features are activated in the site collection), you can set the masterpage in the Publishing Feature with the ChromeMasterUrl property.
If the site is a regular site, you can do 2 things:
deploy the master page from the onet.xml by moving the <Module> from your masterpage feature to the onet.xml, more info here (figure 1).
don't set the masterpage url in the onet, but use a feature + featurereceiver to set the masterpage url, more info here (downloadable code in article).

Resources