WFFM giving error in CMS server - content-management-system

I am using web form for marketer. Its working fine in my local and Dev Server but in CMS environment i am getting following issue :-
[InvalidOperationException: folder]
Sitecore.Form.Core.Configuration.ThemesManager.GetThemeName(Item form, ID fieldID) +434
Sitecore.Form.Core.Configuration.ThemesManager.GetThemeUrl(Item form, Boolean deviceDependant) +250
Sitecore.Form.Core.Configuration.ThemesManager.ScriptsTags(Item form, Item contextItem) +49
Sitecore.Form.Core.Configuration.ThemesManager.RegisterCssScript(Page page, Item form, Item contextItem) +184
Sitecore.Form.Web.UI.Controls.SitecoreSimpleFormAscx.OnInit(EventArgs e) +233
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.AddedControl(Control control, Int32 index) +189
Sitecore.Form.Core.Renderings.FormRender.OnInit(EventArgs e) +846
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.AddedControl(Control control, Int32 index) +189
Efocus.Sitecore.Renderers.SitecoreForm.AddedControl(Control control, Int32 index) +75
Efocus.Sitecore.Renderers.SitecorePlaceholder.OnInit(EventArgs e) +554
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.InitRecursive(Control namingContainer) +291
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098

This response comes a bit late, but I just saw the same issue on a CM environment today. I hope posting this saves somebody some time in the future.
If you look at the stack trace, the exception is thrown at
Sitecore.Form.Core.Configuration.ThemesManager.GetThemeName(Item form, ID fieldID)
This method looks at the Form ID that's configured as the Forms root ID in the site definition.
string formsRootForSite = SiteUtils.GetFormsRootForSite(Context.Site);
Item item = form;
if (form.TemplateID != IDs.FormFolderTemplateID)
{
item = form.Database.GetItem(formsRootForSite);
}
Assert.IsNotNull(item, "folder");
In my case, the configured ID did not match the actual item ID in Sitecore.

Based on the stack trace, it seems you have configured a theme for your site that is not available in your CMS environment.
If you have a scaled instance, make sure all nodes have WFFM installed, even the content delivery servers. Instructions for Content Delivery server installation are in the WFFM administrator's documentation.
If it is not a scaled instance, you may be missing a folder on the system for the Theme that you have specified.

Related

How to make Keycloak 20.0.1 send an e-mail when a user is blocked due to too many failed login attempts?

I want Keycloak to send an e-mail to a user whenever a user is blocked due to too many failed login attempts (see section Realm Settings -> Security defenses -> Brute force detection).
The event in question has the following properties:
Error (org.keycloak.events.Event#getError) = user_temporarily_disabled
Type (org.keycloak.events.Event#getType) = LOGIN_ERROR
How can I do that, i. e. make Keycloak send an e-mail to the user when such event occurs?
Known ways to implement it
One obvious way to do it is to write a class that implements the org.keycloak.events.EventListenerProvider interface, detect the event in its onEvent method and trigger sending of the e-mail at some custom server (i. e. send a request to that server and it will contact an SMTP server).
Second is a variation: Detect the event in the same method and somehow make Keycloak send the e-mail using Keycloak SMTP settings ("Realm settings -> Email -> Connection & Authentication").
The screenshot in this answer made met think (possibly wrongly) that there may be a way to make Keycloak send emails upon the occurrence of certain events "out of the box," i. e. without writing custom event listeners.
Update 1: If someone else wants to do this, I recommend to look at this answer. The code below worked for me.
RealmModel realm = this.model.getRealm(event.getRealmId());
UserModel user = this.session.users().getUserById(event.getUserId(), realm);
if (user != null && user.getEmail() != null) {
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>" + user.getEmail());
org.keycloak.email.DefaultEmailSenderProvider senderProvider = new org.keycloak.email.DefaultEmailSenderProvider(session);
try {
senderProvider.send(session.getContext().getRealm().getSmtpConfig(), user, "test", "body test",
"html test");
} catch (EmailException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Keycloak does indeed support sending emails for events out of the box. However, it can only be configured by event (LOGIN_ERROR), and not by further filtered types (user_temporarily_disabled).
For this, you will need to implement your own EventListener, but it should be easy to heavily copy code from Keycloak's existing EmailEventListener, which you can find here: https://github.com/keycloak/keycloak/blob/main/services/src/main/java/org/keycloak/events/email/EmailEventListenerProvider.java
In there, you'd change the implementation of L59 in onEvent(Event event) to check your two conditions (event type and error), rather than checking against some list of configured fixed events. Your event will be added to the currently running transaction, and when the transaction ends (in success or error), Keycloak will send an email via the SMTP settings that are configured in the realm.
If you want to customize the template and subject lines of the email, you'll have to provide your own freemarker templates in src/main/resources/theme-resources/templates/{html,text}. Both the html and text folder need to contain an .ftl file of the same name. Message keys for use in the template and the subject go in src/main/resources/messages/messages_{en,fr,de,...}.properties files.
With the template and messages configured, you can use one of the 2 send(...) methods available in the EmailTemplateProvider class

Umbraco Forms An item with the same key has already been added

I are running Umbraco 7.4.5 with Dialogue 1.1 fanoe starter kit and Forms 4.3.3.
I have created a contact form and tested. all works great.
Now created and entire new form gathering entirely different information and put it on its own page. Are calling this for Dialogues when a user is not permitted to access to a topic.
Now I get this error when ever I try to submit either form.
An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An item with the same key has already been added.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: An item with the same key has already been added.]
Umbraco.Core.Cache.HttpRuntimeCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem, Nullable1 timeout, Boolean isSliding, CacheItemPriority priority, CacheItemRemovedCallback removedCallback, CacheDependency dependency) +963
Umbraco.Core.Cache.HttpRuntimeCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem, Nullable1 timeout, Boolean isSliding, CacheItemPriority priority, CacheItemRemovedCallback removedCallback, String[] dependentFiles) +107
Umbraco.Core.Cache.DeepCloneRuntimeCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem, Nullable1 timeout, Boolean isSliding, CacheItemPriority priority, CacheItemRemovedCallback removedCallback, String[] dependentFiles) +114
Umbraco.Forms.Core.Cache.CacheProviderExtensions.GetCacheItem(IRuntimeCacheProvider provider, String cacheKey, Func1 getCacheItem, Nullable1 timeout, Boolean isSliding, CacheItemPriority priority, CacheItemRemovedCallback removedCallback, String[] dependentFiles) +225
Umbraco.Forms.Data.StringHelper.ParseMemberPlaceholders(String value, Object memberKey) +1600
Umbraco.Forms.Data.StringHelper.ParsePlaceHolders(HttpContext context, Record record, String value) +390
Umbraco.Forms.Data.StringHelper.ParsePlaceHolders(Record record, String value) +61
........
If I delete the secound form in the backoffice (under Forms) the contact form works.
Has anyone got any surgestions where I start.

Assign site template to organization site programmatically in liferay 6.1.0

I have created user & organization pragmatically using addUser() & addOrganization() methods respectively.
I am also able to add users to this organization using addOrganizationUsers() method.
Now I have created a site template from liferay control panel.
As we know , we can create a site for organization, and while creating a site we have options to select a site template for public & private pages.
As we know .
Public page - Visible to members + non members
Private page - Visible to only members.
So I want to create a organization site with private pages only so it will be seen by only organization member.
OrganiztionLocalServiceUtil.addOrganization(
long userId, long parentOrganizationId, String name, String type,
boolean recursable, long regionId, long countryId, int statusId,
String comments, boolean site, ServiceContext serviceContext)
Using above method , by specifying boolean site value 'true' a site will get created.
Now I want to add a site template to this organization site pragmatically which I have created from control panel.
So is there any API to add site template to any site of organization
Unfortunately there is no public API for it.
Use LayoutSetPrototypeLocalServiceUtil to get the ID for the SiteTemplate. To get the SiteTemplate by name you'll have to either use a dynamicQuery or iterate over the result of LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototypes(-1, -1)
Then invoke applyLayoutSetPrototypes of SitesUtil in the context of the portal.
MethodKey methodKey = new MethodKey("com.liferay.portlet.sites.util.SitesUtil","applyLayoutSetPrototypes", Group.class, long.class, long.class, ServiceContext.class);
PortalClassInvoker.invoke(false, methodKey, organization.getGroup(), publicLayoutSetId, privateLayoutSetId, serviceContext);
Specify -1 for publicLayoutSetId.
An Admin has to be logged in to perform this action.
To perform this action on startup or in the background a new ServiceContext would be needed.
Something like the following
ServiceContext serviceContext = new ServiceContext();
serviceContext.setAddGroupPermissions(true);
serviceContext.setAddGuestPermissions(true);
serviceContext.setSignedIn(false);
// set the following to an admin user / company or default user
User user = UserLocalServiceUtil.getDefaultUser(companyId); // or any user that has the permissions
serviceContext.setUserId(user.getUserId());
serviceContext.setCompanyId(companyId);
And most likely you also have to setup the ThreadPermissionChecker
PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker adminPermissionChecker = PermissionCheckerFactoryUtil.create(user, false);
PermissionThreadLocal.setPermissionChecker(adminPermissionChecker);
Don't forget to reset the permission checker in a final block otherwise the same permission checker might be used for other requests on the same thread.

SSRS - Custom Code

I'm trying to access a REST service from a function written in the custom code of a report. I don't want to move that code into a separate assembly so the problem is around the custom code, please don't send me to custom assemblies.
Here's the code:
Public Shared Function GetData(ByVal id As String) As String
Dim strURL As String = ("http://..." & id)
Dim webRequest As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(strURL), System.Net.HttpWebRequest)
webRequest.Method = "Get"
Dim webResponse As System.Net.HttpWebResponse = DirectCast(webRequest.GetResponse, System.Net.HttpWebResponse)
Dim rdr As New System.IO.StreamReader(webResponse.GetResponseStream)
Return rdr.ReadToEnd
End Function
When I'm using it i receive the error:
System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(String requestUriString)
at ReportExprHostImpl.CustomCodeProxy.GetData(String what, String id, String defaultValue)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Net.WebPermission
The Zone of the assembly that failed was:
MyComputer
And I suppose that I may have future problems with System.IO too.
I had a look on CAS and I'm totally blurred, I don't know what policy file I have to change, what code group I have to change and how.
My understanding is that this is the code group used for custom code (in rssrvpolicy.config):
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="Execute"
Name="Report_Expressions_Default_Permissions"
Description="This code group grants default permissions for code in report expressions and Code element.>
<IMembershipCondition
class="StrongNameMembershipCondition"
version="1"
PublicKeyBlob="002400...CAEDDA2"
/>
</CodeGroup>
but simply setting the PermissionSetName to Fulltrust doesn't make any change.
For anyone experiencing this issue (a year and a half after the fact), if you are receiving this exception when trying to view the report from BIDS, then you need to update the RSPreviewPolicy.config file in your Visual Studio's PrivateAssemblies directory.
There are three security policy files that need to be modified for uses like this (custom code in expression or custom assemblies.) Detailed notes (including a seriously crucial one on where to place new CodeGroup elements!!) can be found on the MSDN page titled (as of today) "Using Reporting Services Security Policy Files". The security config files are the report server config (rssrvpolicy.config), the report manager config (rsmgrpolicy.config) and the report designer config (RSPreviewPolicy.config).
A great test for this is to update one at a time and test all three after each update (after deploying a report to your report server instance of course : ).
You should try PermissionSetName="FULLTRUST" in the codegroup.

Workflow persistence - WebServiceInputActivity

alt text http://home.elka.pw.edu.pl/~pkolodzi/Capture.PNG
I have created the IAdder interface with two methods: PassA and PassB. My workflow starts with webServiceInputActivity1 which is activated by PassA remote call. Another element in my workflow is another webServiceInputActivity2 element. This time the "IsActivating" property is set to false. I expect my workflow to be persisted after first activity finishes (which does return void). The workflow should be reactivated by calling PassB web method.
After publishing workflow as web service and invoking PassA here is what I get:
System.InvalidOperationException: Workflow with id "b0c5f9dd-57f3-427f-b172-17d4663f7eaf" not found in state persistence store.
at System.Workflow.Runtime.Hosting.PersistenceDBAccessor.RetrieveInstanceState(Guid instanceStateId, Guid ownerId, DateTime timeout)
at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.LoadWorkflowInstanceState(Guid id)
at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
at System.Workflow.Activities.WorkflowWebService.Invoke(Type interfaceType, String methodName, Boolean isActivation, Object[] parameters)
at PersistanceWebServiceWorkflow.Workflow1_WebService.PassA(Int32 a) in C:\Users\djpiter\AppData\Local\Temp\2dnwfnsn.cs:line 39
Do you have any ideas what I do wrong?
ps:( The database is properly set. I tested it on workflow hosted in console app and delay activity .I also added necessary line to web.config file. )
Kind Regards
PK
If one of your activities would throw an exception, the workflow state information would be deleted from the database. Run your workflow debugger with "break when exception is throw" configured in Debug - Exceptions - Common Language Runtime Exceptions