Blog posts by Fredrik von Werder2008-10-01T20:18:25.3070000Z/blogs/Fredrik-von-Werder/Optimizely WorldEPiServer Authentication using Kerberos and Custom App Pool Identity/blogs/Fredrik-von-Werder/Dates/2008/10/EPiServer-Authentication-using-Kerberos-and-Custom-App-Pool-Identity/2008-10-01T20:18:25.3070000ZThis article describes how to get Kerberos handshake to work when the website is running with a pre configured account. It will only happen if you are browsing to the "computer's name", otherwise NTLM is used, which is the most common scenario. <br /><br />I recently had a hard time to get Windows authentication working properly. <br /><br />I installed a standard EPiServer CMS SP3, with Authentication mode "windows", and configured the site to use integrated security against the Sql Server. <br /><br />This was going to be the intranet site, or at least the test site for the intranet. <br /><br />The window dialog appeared and despite supplying all kinds of usernames and passwords, the site refused to accept my credentials. <br /><br />What has happened? This is usually working fine out of the box with a minimum of necessary brain activity. <br /><br />It took half a day before I found the solution, and I hope that anyone that encounter the same problem, will find some help here. <br /><br /><span class="fullpost"><br /><br /><span style="font-size: 130%"><strong>Problem</strong> <br /></span><br />The problem was that the site (Application pool) was running under a custom identity, and that browsing was against the computer name, which means that <strong>Kerberos </strong>authentication is being used. <br /><br />Browsing with the IP or the DNS alias, was no problem at all, since NTLM handshake works fine. Single sign on without any hesitation. <br /><br /><span style="font-size: 130%"><strong>Solution</strong> </span><br /><br />Log on the webserver using a <strong>domain admin account</strong>. <br /><br />Download the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5fd831fd-ab77-46a3-9cfe-ff01d29e5c46&displaylang=en">SPN tool</a>, and install it. <br /><br />Start command prompt in the same directory as you installed setspn. <br /><br />Use the setspn command to authenticate the account on the server/domain. <br />Syntax: <br />setspn -A HTTP/<servername> <domain>\<account> <br /><br />example: <br />"setspn -A HTTP/srv01 domain1\episervice" <br />"setspn -A HTTP/srv01.mycomppany.com domain1\episervice" <br />etc <br /><br />You must authenticate all hosts, otherwise it won't work. <br /><br />You can list all hosts with "setspn -l <servername>" <br /><br /><br />Note that this is only necessary to do when you run the website under a pre configured account, in other more common scenarios, the Kerberos authentication will work just fine. <br /></span>ASP.NET 3.5 Extension - Translate a String/blogs/Fredrik-von-Werder/Dates/2008/9/ASPNET-35-Extension---Translate-a-String/2008-09-27T18:18:55.0000000Z<p>Using Google translations, translate a string to (almost) any language.</p> <p>Since it is an extension, it will be available like myString.Translate("sv","en"); but you can of course use it as a regular method by removing the arg 'this string s'.</p> <p>Note that the web server must be able to make web requests to google.com.</p> <p>You can use both codes like "en" or the culture and lang "sv-SE" version (takes the first one)</p><span class="fullpost"> <h3>C# code:</h3><pre class="language-csharp"><code><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Text;
<span style="color: blue">using </span>System.Net;</code></pre><a href="http://11011.net/software/vspaste"></a>
<div align="left"><pre class="language-csharp"><code><span style="color: blue">public static string </span>Translate(<span style="color: blue">this string </span>s, <span style="color: blue">string </span>langFrom, <span style="color: blue">string </span>langTo)
{
<span style="color: blue">if </span>(<span style="color: #2b91af">String</span>.IsNullOrEmpty(s))
<span style="color: blue">return </span><span style="color: #2b91af">String</span>.Empty;
<span style="color: blue">if </span>(langFrom.Contains(<span style="color: #a31515">"-"</span>))
langFrom = langFrom.Split(<span style="color: #a31515">'-'</span>)[0];
<span style="color: blue">if </span>(langTo.Contains(<span style="color: #a31515">"-"</span>))
langTo = langTo.Split(<span style="color: #a31515">'-'</span>)[0];
<span style="color: blue">string </span>address = <span style="color: blue">string</span>.Format(<span style="color: #a31515">"http://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}%7C{2}"</span>, s, langFrom, langTo);
<span style="color: blue">string </span>html = <span style="color: blue">new </span>WebClient().DownloadString(address);
<span style="color: blue">string </span>block = html.Substring(html.IndexOf(<span style="color: #a31515">"id=result_box"</span>) + 0x18, 500);
<span style="color: blue">string </span>phrase = block.Substring(0, block.IndexOf(<span style="color: #a31515">"</div"</span>));
<span style="color: blue">return </span>phrase;
}</code></pre><a href="http://11011.net/software/vspaste"></a><pre class="language-csharp"><code> </code></pre><a href="http://11011.net/software/vspaste"></a></div><a href="http://11011.net/software/vspaste"></a></span>Edit language xml files - EPiServer CMS 5http://fredrikvonwerder.blogspot.com/2008/07/edit-language-xml-files-episerver-cms-5.html2008-07-16T23:15:00.0000000ZToday I came across a small issue with the language xml files that developers create for each project. The customer just wants to edit the text translations, not adding elements or changing anything in the xml schema. This seems like a pretty useful thing for an editor, but there isn't anything available in EPi for this. I looked at the EPiCode's ManageLanguages but it was not capable of The Beat From Palookaville - a Ska band I play inhttp://fredrikvonwerder.blogspot.com/2008/07/beat-from-palookaville.html2008-07-16T00:04:00.0000000ZI play in a nice band called The Beat From Palookaville, and we play Ska songs like Blues Busters and covers of Rehab and Ring Of Fire, in Ska versions of course. Here is a video from Stampen in Stockholm (Sweden) earlier this year. I'm behind the horn section most of the time, but becomes visible during the organ solo :-) YouTube - Stampen-Palookaville Recycle Bin safe delete - ActionWindow Gui PlugIn EpiServer 4.60http://fredrikvonwerder.blogspot.com/2008/07/actionwindow-plugin-in-episerver-460.html2008-07-15T20:55:00.0000000ZDelete pages from Recycle Bin safely. This one has an option for languages, but that can easily be removed. This is how it will look like, using the complete code below Create file RecycleBinHandler.ascx (Change 'EditThis' to something meaningful) Markup: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RecycleBinHandler.ascx.cs" Inherits="Find any value anywhere - ActionWindow Gui Plug-In EPiServer 4.60http://fredrikvonwerder.blogspot.com/2008/07/actionwindow-plugin-in-episerver-462.html2008-07-15T19:46:00.0000000ZThis is a simple and neat little function that can come in handy sometimes. Imagine you have an error message saying like "Could not find page 7103", when you are accessing the start page for example. And you realize that the page is in recycle bin. But you dont know how (or have the patience) to go through all possible items looking for properties with a PageReference pointing to that page.