Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 22, 2009 @ 17:28
    Jamie Howarth
    10

    Umbraco in Medium Trust

    Hi all,

    Am a new forum member but I just thought I'd let people know that I've made a few tweaks to the Umbraco source code and I've successfully got a dev build of Umbraco 4 on Windows 7 w/IIS7 (Integrated pipeline mode) running in Medium Trust. I'll also try and get hold of a test IIS6 environment over the next few days along with testing the IIS7 site in Classic app pool mode so I can ensure that my code is totally stable.

    I've seen a lot of people dying to get hold of this info and I've just downsized from a dedicated server to shared hosting so I needed Umbraco to work in Medium Trust otherwise I would've been forced to go back to the horrors of DotNetNuke... *shudder*.

    Main kudos goes to Brendan Tompkins for refactoring his image quantization library to not use unsafe members, which I took three files from (OctreeQuantizer.cs, PaletteQuantizer.cs and Quantizer.cs) and recompiled into ImageManipulation.dll (will post up along with a recompiled umbraco.providers library and full source for both libs). And of course, to Niels for making Umbraco open-source, otherwise I wouldn't have been able to remove the huge culprit from the umbraco.providers library (SecUtility.cs, lines 137-146):

    if (string.IsNullOrEmpty(applicationVirtualPath)) {
        applicationVirtualPath = Process.GetCurrentProcess().MainModule.ModuleName;
        int index = applicationVirtualPath.IndexOf('.');
        if (index != -1) {
            applicationVirtualPath = applicationVirtualPath.Remove(index);
        }
    }

    According to MSDN, Process.GetCurrentProcess() requires Full trust. Simply commenting out these lines and recompiling the umbraco.providers library seems to do the job rather nicely (although I'd rather find an alternative method instead of using Process.GetCurrentProcess - suggestions on a postcard please) - I've just rebuilt the website and installed Blog4Umbraco (while still running Medium trust) and it appears to have installed fine although I've yet to do masses of extensive testing. However, early indications are very positive.

    Hope this all helps.

    Benjamin

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 22, 2009 @ 17:49
    Jamie Howarth
    0

    P.S. I haven't tested the installation process in Medium Trust - I installed in Full Trust first locally so I'll give that a go a little later on today.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 22, 2009 @ 19:26
    Jamie Howarth
    0

    P.P.S. Niels, I just found a use for that "UseMediumTrust" appsetting:
    if ((string.IsNullOrEmpty(applicationVirtualPath)) && (GlobalSettings.UseMediumTrust == false))

    I'll throw together a whole blog post when I've moved my DNN blog site to Umbraco and Blog4.

    :-)

  • Rich Green 2246 posts 4008 karma points
    Dec 23, 2009 @ 11:32
    Rich Green
    0

    Looking forward to that Benjamin.

    Keep up the good work!

    Rich

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Dec 23, 2009 @ 11:59
    Sebastiaan Janssen
    0

    Not that I need any of this, but I love that you're working on this, great stuff and I'll try to follow the progress of your endeavor.

  • Adriano Fabri 458 posts 1601 karma points
    Dec 23, 2009 @ 16:25
    Adriano Fabri
    0

    Hi Benjamin,
    Few time ago I tried to run umbraco in a domain with medium trust configuration.
    I also tried to make some changes to web.config but I didn't succed.

    Now I'm really interested to your discussion.
    Could you give me more details on what I should do to succeed?

    Thank you
    Adriano

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 23, 2009 @ 17:13
    Jamie Howarth
    2

    Hey guys,

    Let me give you the breaking news over the last 24 hours since I OP'd:

    • "Medium Trust" worked great, only because I added the <trust> element to a web.config on an existing Umbraco installation which had been previously run in Full Trust. So, I could log in & stuff but then discovered that not a lot of stuff worked and that I'd also really like to get the installation process running under Medium Trust.
    • I have four environments that I'm currently running on:
      • Win7, IIS7;
      • WinServer2008, IIS7.5;
      • Win7, Visual Studio 2008 "Cassini";
      • WinXPPro, IIS5.1.
      I figure that this should cover most of my needs - i.e. if it works on IIS5.1, it'll work on IIS6, then I only have to concentrate on running on IIS7/7.5 in both Integrated and Classic mode.
    • First hurdle after the above two (ImageManipulation and RoleProvider) - getting the RoleProvider to play nicely, I got a very generic "request failed" error, which came from the above SecUtility.cs line. This comes into play a little later on as well cause it's not just the RoleProvider that uses this function.
    • Second hurdle - the current XMLRPC.Net library in use in Umbraco is 2.2.x, which needs FileIOPermission on something (not sure what, but it's issue 55 on Google Code, fixed at end of June 09), which isn't available in Medium Trust. Downloading version 2.4.x and updating all references in source Umbraco to use new XMLRPC.Net library, then rebuilt all Umbraco DLLs accordingly. Errors referencing Umbraco channel api paths in web.config now disappear. Woop :-)
    • Still to do - Running on Cassini works up until changing the default admin password, which requires the UmbracoMembershipProvider, which for some reason isn't recognising that I changed the SecUtility.GetDefaultAppName() method (and rebuilt the library) and still throws "Request failed" cause it tries to call Process.GetCurrentProcess() (see OP). When moving built libraries to Server08/IIS7.5, connection to SQL Server fails. Am currently debugging these two steps by clearing out temporary .NET files and I'll post back later with (hopefully) some good news.

    The main exercise of doing this is to be able to run a full installation of Umbraco 4.0.x, on any version of IIS between 5.1 and 7.5, and connect to SQL Server (I would test things like VistaDB but I'm gonna be running Umbraco with SQL Server, so I'm not hugely interested if that's buggy at present, although when I find the time I'm sure I'll probably take a crack at those too just to make sure they work).

    Adriano, I am making changes to the core Umbraco libraries in places (umbraco.providers, umbraco.imaging.ImageManipulation, and updating all core libs to use CookComputing.XmlRpcV2 v2.4.x), so just changing the web.config won't help you much!

    The work I'm doing on this will be in accordance with the existing Umbraco license along with various other attributions, credits etc. I am keeping copious notes and will submit a plethora of tickets on Codeplex when I have finished with the hope that the Umbraco team will make small tweaks here and there to the Umbraco code accordingly. Most of it is just specific lines of code where alternate "safer" methods can be used (like XMLRPC.Net and ImageManipulation being rewritten/replaced, avoiding Process.GetCurrentProcess(), not using HttpRuntime cause some members aren't accessible cause you need FileIOPermission - little things like that).

    FYI: I'm using the latest stable source build (according to Codeplex) which you can get from here.

    Thanks for all the support :-)

    Benjamin

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 27, 2009 @ 00:34
    Jamie Howarth
    0

    OK guys,

    http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=25788

    My hitlist of stuff to make Umbraco work on Medium Trust. I've only run this on Cassini on Windows 7 Ultimate but it runs, installs and works.

    Will be testing more thoroughly on Windows XP (IIS5.1), along with Integrated Mode on Windows Server 2008 (IIS7.5) and Windows 7 (IIS7).

    The impossible has been achieved :-)

    Benjamin

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 27, 2009 @ 01:40
    Jamie Howarth
    2

    Update: I have submitted one ticket and two patches on Codeplex, and have successfully run the entire installation procedure on Windows 7 x64 and Server 2008 x64 with IIS7.5 and SQL Server 2008, both work perfectly :-)

    Let's hope my work gets submitted to the next releases!

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 27, 2009 @ 14:14
    Jamie Howarth
    1

    I'll also put up a fully-built copy that people can download from my website once my website is actually built on my shiny new edition of Umbraco :-D

  • amunk 17 posts 32 karma points
    Dec 27, 2009 @ 16:44
    amunk
    0

    Excellent work, Benjamin! Thanks for sharing info.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 27, 2009 @ 20:51
    Jamie Howarth
    0

    Latest info - I've just tested and successfully installed on a GoDaddy shared hosting account (IIS7, medium trust, unsure of OS) an Umbraco build. I had to run the database scripts manually but once those were in place everything worked flawlessly.

  • Tom 50 posts 100 karma points
    Dec 27, 2009 @ 21:20
    Tom
    0

    Excellent work, Benjamin!

    @All, please vote for this issue http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=25788 at codeplex.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 27, 2009 @ 23:28
    Jamie Howarth
    0

    Was about to ask that meself! Thanks Tom :-)

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Dec 28, 2009 @ 00:01
    Niels Hartvig
    0

    Awesome work - only thing that needs change is the usage of "HttpContext.Current.Server.MapPath("~")" in globalsettings as some calls in Umbraco doesn't have an httpcontext (threaded tasks) - any way around that?

     

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 02:48
    Jamie Howarth
    0

    Let me have a look at what calls that GlobalSettings method and see if that could potentially be a problem. The downside is that using the Process.GetCurrentProcess() forces the library to compile with high/full trust which means the whole build dies, the HttpContext one was the first thing that sprang to mind.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 03:01
    Jamie Howarth
    1

    OK, 9 calls to GlobalSettings.FullpathToRoot in the entire Umbraco project (with the exception of the FullpathToRoot declaration itself):

     

    • C:\inetpub\www-umbrsource\components\editorControls\tinymce\tinyMCEConfiguration.cs - (105, 36) : xd.Load(GlobalSettings.FullpathToRoot + System.IO.Path.DirectorySeparatorChar + GlobalSettings.Path + System.IO.Path.DirectorySeparatorChar + ".." + System.IO.Path.DirectorySeparatorChar + "config" + System.IO.Path.DirectorySeparatorChar + "tinyMceConfig.config");
    • C:\inetpub\www-umbrsource\umbraco\businesslogic\UmbracoSettings.cs - (30, 54) : private static string _path = GlobalSettings.FullpathToRoot + Path.DirectorySeparatorChar + "config" +
    • C:\inetpub\www-umbrsource\umbraco\cms\businesslogic\CMSNode.cs - (41, 78) : private static readonly string m_DefaultIconCssFile = GlobalSettings.FullpathToRoot + GlobalSettings.Path + System.IO.Path.DirectorySeparatorChar + "css" + System.IO.Path.DirectorySeparatorChar + "treeIcons.css";
    • C:\inetpub\www-umbrsource\umbraco\cms\businesslogic\index\Indexer.cs - (35, 58) : _indexDirectory = GlobalSettings.FullpathToRoot + RelativeIndexDir;
    • C:\inetpub\www-umbrsource\umbraco\cms\businesslogic\template\Template.cs - (36, 41) : get { return GlobalSettings.FullpathToRoot + "masterpages" + System.IO.Path.DirectorySeparatorChar + Alias.Replace(" ", "") + ".master"; }
    • C:\inetpub\www-umbrsource\umbraco\cms\businesslogic\template\Template.cs - (532, 50) : string _oldFile = GlobalSettings.FullpathToRoot + "masterpages" + System.IO.Path.DirectorySeparatorChar + _oldAlias.Replace(" ", "") + ".master";
    • C:\inetpub\www-umbrsource\umbraco\presentation\install\steps\validatePermissions.ascx.cs - (109, 58) : new DirectoryInfo(GlobalSettings.FullpathToRoot + Path.DirectorySeparatorChar + "config").
    • C:\inetpub\www-umbrsource\umbraco\presentation\template.cs - (55, 58) : if (System.IO.File.Exists(GlobalSettings.FullpathToRoot + "masterPages" + System.IO.Path.DirectorySeparatorChar + file))
    • C:\inetpub\www-umbrsource\umbraco\presentation\umbraco\developer\Xslt\xsltVisualize.aspx.cs - (39, 56) : System.IO.File.OpenText(GlobalSettings.FullpathToRoot + GlobalSettings.Path.TrimStart('/') + System.IO.Path.DirectorySeparatorChar +
    One can safely assume that any calls to FullpathToRoot from within umbraco.presentation will have HttpContext, which means the last three from the above can be ignored. Any clues on the others? At first glance they all look to be fairly harmless...

     

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 04:33
    Jamie Howarth
    1

    Last but not least (before I get some sleep):

    1. SQL installation step fails with a NotSupportedException, trying to debug why...
    2. A working build has been uploaded to www.codegeckodevelopments.com/Umbraco403-MediumTrust.zip. This contains my latest build which was installed on a GoDaddy shared hosting account on IIS7 in Medium Trust (warning to those using their free accounts, they inject advertising in the header of every request, which includes AJAX calls in the admin interface, as I discovered! Recommend you spend $5/month-ish to get a non-ad-peppered account).
      This ZIP also includes the SQL scripts that create the Umbraco schema for SQL Server. Total.sql is for a clean install, Version3_Upgrade should be self-explanatory. Run either (not both) of these on your database before running the Umbraco installation process.
    Notes/disclaimer:
    This is not an official release of Umbraco. Use at your own risk. No warranties, guarantees, claims of fitness for purpose or suitability etc. and standard Umbraco license applies (MIT-style license, credit/attribution and beer money would be lovely!) Please reply to thread or add comments to this item on Codeplex with any other bugs as I'll be keeping a close eye on it.
    Apart from that, enjoy :-)

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 04:48
    Jamie Howarth
    0

    OK, total my bad, HttpRuntime.AppDomainAppPath seems to be working fine on my shared host. Feel free to ignore that on the patch I uploaded, will also amend my ZIP file accordingly.

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Dec 28, 2009 @ 08:28
    Niels Hartvig
    0

    No matter what, it seems that HostingEnvironment.ApplicationPhysicalPath is the correct approach, so we might as well update anyways. Looks like it works fine in medium trust as well :-)

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 12:24
    Jamie Howarth
    1

    Awesome - just updated my end and rebuilt. Now my final hurdle - to work out why the SQL installation step fails. Then the whole thing end-to-end works. Woop :-D

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 13:56
    Jamie Howarth
    1

    Just submitted another patch - under GlobalSettings, protected internal SaveSetting, I had replaced the code that accessed the web.config to use AppSettings.Set(), but have just discovered that this only updates the ASP.NET cached NameValueCollection, not the web.config itself (kinda pointless, really). However, using OpenMappedExeConfiguration requires read access on all configuration files that a specific config inherits from - all web.config's inherit from machine.config, which in Medium Trust is outside the app root and therefore throws a FileIOException due to lack of permission. Have replaced this with OpenExeConfiguration which only opens a single config without attempting to load inherited settings.

    Niels, have also added the HostingEnvironment.ApplicationPhysicalPath code to this patch as well.

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Dec 28, 2009 @ 15:38
    Niels Hartvig
    0

    What about xslt extensions (such as umbraco.library:NiceUrl in xslt) - does that work in medium trust as well?

    Then it's W00t!!!

  • bob baty-barr 1180 posts 1294 karma points MVP
    Dec 28, 2009 @ 16:41
    bob baty-barr
    0

    wow, this has been a fun thread to follow... when Benjamin gets this working, a whole new world can open up to umbraco! very exciting stuff... thanks for all the efforts @Benjamin! + 1 all around!

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 16:57
    Jamie Howarth
    0

    @Niels I'll have a look! Also found a bug in Blog4Umbraco (I'm a inquisitive chap).

    @Bob Thanks :-)

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 17:26
    Jamie Howarth
    0

    @Niels I'll have a look! Also found a bug in Blog4Umbraco (I'm a inquisitive chap).
    Update: umbraco.library:NiceUrl does appear to work, having checked the XSLT in Blog4Umbraco which makes use of it.

    @Bob Thanks :-)

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Dec 28, 2009 @ 17:38
    Chris Houston
    0

    @Benjamin, great work! I just added a comment on the codeplex bug page you created and then found this thread over on the forum :)

    I see Niels has already mentioned the XSLT extensions, my fingers are crossed that you manage to get them working too!

    Cheers,

    Chris

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 18:02
    Jamie Howarth
    0

    Hi Chris, yes, it appears that XSLT extensions work fine in Medium Trust (I've installed Blog4Umbraco in a medium trust build, there's a bug on the Blog4Umbraco Codeplex project page but the extensions seem to work fine in themselves).

    My current hitlist is as follows:

    • SQL installer not fully functioning in Medium Trust - unsure as to why.
    • Blog4Umbraco has a bug;

    Apart from that all other Umbraco functionality seems to work as intended. I'll update my ZIP'd build so people can download and play later.

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Dec 28, 2009 @ 18:07
    Sebastiaan Janssen
    0

    Benjamin, do you think I can just copy your /bin folder into mine and see if everything still works?

    I have a few packages and a lot of custom code that I'd like to test, be easier if I don't have to overwrite EVERYthing. :-)

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 18:20
    Jamie Howarth
    0

    Lol. I'll re-zip my build in a little while. Just a quick update - <msxsl:script> blocks don't work but Exslt and umbraco.library extensions appear to be fine. Debugging as we speak.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 18:39
    Jamie Howarth
    0

    Aha. This is probably why the discussion about running in Medium Trust halted previously: http://social.msdn.microsoft.com/Forums/en-US/xmlandnetfx/thread/b643e335-f1b4-4fb3-b81f-f4ace3f156fa (and I paraphrase): Using XsltSettings.TrustedXslt basically means you cannot run in Medium Trust because it allows <msxsl:script> blocks.

    However... (thinking aloud here) if you ran with <msxsl:script> blocks disabled, is that such a bad thing? All the Exslt functionality (and as far as I can see, the umbraco.library code) makes use of a compiled library with declared namespaces in the necessary XSLT files. If people want to create their own XSLT code in the "proper" fashion (class lib with XPathNodeIterator, then expose in a namespace declaration in XSLT) then surely this is more secure than allowing <msxsl:script> blocks - as it then puts the emphasis on writing secure code for Medium Trust onto the developer for writing their XSLT extension in a secure fashion.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 28, 2009 @ 18:57
    Jamie Howarth
    0

    Please see item #4754 here - rewritten code to use XsltSettings.Default when transforming macros using a test for GlobalSettings.UseMediumTrust or GlobalSettings.ApplicationTrustLevel is equal to AspNetHostingPermissionLevel.Medium, tested on IIS7 Integrated mode shared hosting with Godaddy. Works a charm :-)

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Dec 28, 2009 @ 21:55
    Douglas Robar
    0

    What an awesome effort, Benjamin! It would be a huge advance to get umbraco running well in medium trust.

    As for <msxsl:script> blocks... I'm one of those that use them. The reason is that I often need some little utility function and it isn't worth creating a whole xslt extension for it. Since I'm not a hard-core c# guy and don't live in visual studio as some do, I find it much more convenient to put the odd bit of c# in a script block right in my xslt code. That doesn't make it a requirement for umbraco in medium trust (some things may simply not be possible) but I'm far from the only one who does this in packages and individual projects so it would be a shame to lose if it could somehow be retained.

    One popular umbraco packages is my XSLTsearch, which uses a script block. XSLTsearch is also part of CWS2. That would make the #1 and #9 most popular packages incompatible with medium trust if script blocks are a no-go.

    Having been positively amazed at your ability to get this far with medium trust I hope there's a solution to this as well.

     

    cheers, and thanks again for your great work,
    doug.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 29, 2009 @ 00:15
    Jamie Howarth
    0

    Hi Doug,

    Thanks for the feedback and support :-). I appreciate <msxml:script> blocks might be extremely useful for small snippets of code but to get Umbraco running those in Medium Trust would involve overriding the XslCompiledTransform class in the .NET Framework, which I'd probably be happy to take a crack at but wouldn't be a quick fix. This definition on MSDN of the XslCompiledTransform class explains why enabling script requires full trust and how malicious scripts can exploit <msxml:script> - it also mentions that external assemblies are allowed by default and do not require additional permissions.

    Just took a look through the XSLTsearch code - there's more than 200 lines of C# which I would consider dumping into a .NET assembly (which I'd be happy to do under an MIT license) and refactoring elements of it, I spotted at least one function which is a duplicate of an Exslt helper function already included in Umbraco.

    The bottom line - to be able to run Umbraco on Medium Trust, users and/or module developers will have to sacrifice <msxml:script> and move to external assemblies. Sounds horrible to put it that bluntly, but that is the only sticking point.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 29, 2009 @ 00:32
    Jamie Howarth
    0

    Also - much as some people don't live in Visual Studio, you can add an app_code folder to your Umbraco installation and dump what would normally be inside an <msxml:script> block in a .cs file there, which gets compiled at runtime. That could be the workaround.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 29, 2009 @ 04:53
    Jamie Howarth
    0

    Further update - I used Reflector to check out the XmlCompiledTransform class, basically it derives from System.Data.SqlXml which makes use of a method CompileScripts() that is explicitly stated as requiring full trust, as it compiles anything inside a <msxml:script> block into an assembly on-the-fly at runtime. Sorry to burst the bubble but there is no way of getting anything on .NET to run <msxml:script> on Medium trust.

    As XSLTsearch is licensed under an open-source license I'll rewrite this during this week and submit it to the CWS project on Codeplex for consideration.

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Dec 29, 2009 @ 08:53
    Niels Hartvig
    3

    I'm with Benjamin here. Inline .NET scripting in XSLTs should be a no-go'er. The solution - v4.1 - must be:

    1. Make it easier to build XSLT Extensions by offering an editor for app_code files and make it a one checkbox operation to register an app_code class as an XSLT Extension
    2. Make a check in the XSLT editor looking for msxml:script elements and warn before saving
    @Benjamin: Is it possible to allow msxml:script elements in sites that runs high/full trust and yet still have the same binaries working in medium trust (with msxml:script elements not working naturally)?
    And needless to say, absolutely fantastic work by Benjamin. You're entering the holidays-hacking-hall-of-fame along with Ruben Verbough who made the datalayer in the 2008 christmas holidays - what a tradition :-)
    So 2010 will see an official Umbraco distribution that works in virtual directories, works on mono and works in medium trust. Who would have ever thought that. Best. Community. Ever.
    Best,
    Niels...

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Dec 29, 2009 @ 11:14
    Douglas Robar
    0

    Hi, Benjamin,

    Thanks for the great research on msxml:script blocks; I understand completely. Agree with Niels that (if possible) they should be allowed if in a full-trust environment. Also agree with Niels' other points.

    As you can see from the large XSLTsearch.xslt file, what started as a simple idea for umbraco searching has slowly grown and grown over the years. The goal for XSLTsearch has always been to have it be a one-file solution. I long ago added c# functions to speed up and augment xslt's built-in capabilities, while still keeping as much as possible in xslt itself. Seems I will now need to move beyond the one-file solution. To at least keep with the easy-to-edit-and-learn-from goals I (or you) should use app_code instead of a pre-compiled dll for the xslt extension. It's a straightforward update so don't waste time with it unless it is interesting to you... the work you're doing on medium trust is MUCH more important at this stage.

    If you do make any updates to XSLTsearch, just email them to me and I'll merge it into the next XSLTsearch update for umbraco 4.1. I'll be sure to get the update to Warren for his CWS2 package as well.

    @Niels... Lee Kelleher has done some work on adding an app_code editor based on TimG's config folder code. Give him a shout; maybe that is already nearly done!

    cheers,
    doug.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 29, 2009 @ 17:56
    Jamie Howarth
    1

    @Niels: Yes, the patch I submitted on Codeplex already accommodates for that - checks for medium trust and applies XsltSettings.Default (script disabled) if in medium trust, and runs with XsltSettings.TrustedXslt (script enabled) if not in medium trust. Point 2 should be easy enough - simply test if editing an XSLT, then parse it into an XmlDocument and find the <msxml:script> elements - if they exist, return to GUI with an error. Point 1 - if Lee Kelleher has already started this then it might be a good idea to see if it's merge-able into the main project trunk, I'll follow him on Twitter and see if I can check the source cause all that code has to be able to run in medium trust too.

    @Douglas I've added you on Twitter so DM me your email address so I can send over an amended codeblock for integrating into XSLTsearch/CWS.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 30, 2009 @ 05:21
    Jamie Howarth
    0

    And the final clincher - patch #4768 on Codeplex, additions to macro.cs which compiles public classes in the App_Code folder into XSLT extension objects. With this code you can add a .cs file to the App_Code directory and add xmlns:yourprefix="yournamespace.yourpublicclass" and execute static methods within the class accordingly, instead of having to compile XSLT extensions to a class library and add it to /config/xsltExtensions.config.

    One word. Woop :-)

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Dec 30, 2009 @ 10:42
    Douglas Robar
    0

    As usual, amazing functionality and progress! A couple questions from one who knows xslt much better than c#...

    1. All Runway Modules must use the app_code folder rather than compiled dlls (that's a requirement for runway modules) and at least the Runway Gallery has a public (though not static) bit of code. 

    namespace Umbraco.RunwayGallery
    {
    public class ZipUploadHandler : umbraco.BusinessLogic.ApplicationBase
    {
    public ZipUploadHandler()
    {
    umbraco.content.AfterUpdateDocumentCache += new umbraco.content.DocumentCacheEventHandler(content_AfterUpdateDocumentCache);

    }

    void content_AfterUpdateDocumentCache(Document sender, umbraco.cms.businesslogic.DocumentCacheEventArgs e)
    { .......

    That code shouldn't be automatically turned into an xslt extension I think.

    2. I love the idea of not having to update the /config/xsltExtensions.config file! But I think it is used to automatically insert the proper 'xmlns' and 'exclude' lines at the top of all new xslt macros (for existing macros you would have to add them by hand). Would that functionality continue to work with your update? If so.... wow!

    I'm writing a tutorial on converting inline xslt script blocks to an app_code xslt extension. Very straightforward but nice to have the procedure documented for those who want to update their full-trust-only xslts to medium trust compatibility.

    cheers,
    doug.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 30, 2009 @ 10:50
    Jamie Howarth
    0

    There is a single function that generates xmlns prefix and exclude-result-prefixes code, yes, my modification sits at this level (although I am not sure if it updates the exclude-results-prefixes, however I will see what magic I can work).

     

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 30, 2009 @ 13:03
    Jamie Howarth
    0

    Idea - that code should only make use of content_AfterUpdateDocumentCache in the same class, right? Make it protected. XSLT extension methods have to be declared as follows to be read:

    1. Be a class definition with a zero-parameter constructor with no code inside the constructor;
    2. Methods must be public and static to be accessible as XSLT extensions.

    Simply make that method protected or internal so it's only accessible from within the class, job done.

     

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 30, 2009 @ 15:42
    Jamie Howarth
    0

    Oh, last but not least, wiki page is here as per Neils' request. I will be fully testing and publishing a build later on today.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 31, 2009 @ 02:33
    Jamie Howarth
    0

    Please check my project and wiki pages, I've uploaded my build of Umbraco 4.0.3 Medium Trust "edition" here. Keep me posted of bugs. I already know about an error in CreatePost.ascx in Blog4Umbraco, and stuff about <msxml:script> blocks has already been covered here and on the wiki page I created.

    Enjoy Umbracians :-)

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Dec 31, 2009 @ 11:26
    Chris Houston
    0

    Hi Ben,

    Unfortunately you have an error on your server that is preventing your file from being downloaded!

    Server Error in '/' Application.

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: Could not load type 'umbraco.presentation.urlRewriter.FormRewriterControlAdapter'.

    Source Error:

    Line 3:    <browser refID="Default">
    Line 4: <controlAdapters>
    Line 5: <adapter controlType="System.Web.UI.HtmlControls.HtmlForm"
    Line 6: adapterType="umbraco.presentation.urlRewriter.FormRewriterControlAdapter" />
    Line 7: </controlAdapters>


    Source File: D:\Hosting\5422566\html\App_Browsers\Form.browser    Line: 5


    Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

    Cheers,

    Chris

     

  • Jamie Howarth 306 posts 773 karma points c-trib
    Dec 31, 2009 @ 12:47
    Jamie Howarth
    0

    Updated and fixed. Try now :-)

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Dec 31, 2009 @ 12:54
    Chris Houston
    0

    Hi Ben,

    Yes the download works now, I'll give it a go and will let you know :)

    Cheers,

    Chris

  • ianhoughton 281 posts 605 karma points c-trib
    Jan 02, 2010 @ 17:53
    ianhoughton
    0

    I tried this morning to get Umbraco running on my IIS6 shared hosting under medium trust:

    1) Had to remove the trust level section out of the web.config file to get the installation to run. My hosting will not allow me to overide the trust settings. The installation ran fine after that.

    2) Installed the CWS2 package ok.

    3) On publishing content, the site errors out with this: "XML Parsing Error: no element found Location: http://testdomain.com/umbraco/editContent.aspx?id=1084 Line Number 1, Column 1:"

    Is this related to the originUrl setting that I have removed from the web.config file ??

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 02, 2010 @ 19:32
    Jamie Howarth
    0

    Hi Ian,

    I've not tested extensively with CWS2 - I know that XSLTsearch had problems which I've rewritten especially and Doug Robar will be blogging about very soon. I'll download it now and test locally and see if I come up with a similar problem. Have also DM'd you on Twitter with my email and MSN so you can add me and we can go through it together.

    Happy to help,

    Benjamin :-)

  • ianhoughton 281 posts 605 karma points c-trib
    Jan 02, 2010 @ 20:25
    ianhoughton
    0

    The domain in my previous post is a dummy, didnt want to show the correct one, sorry for any confusion.

    I have also tried adding the runway modules to a virgin install, I get the same error message when trying to publish a node.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 03, 2010 @ 18:04
    Jamie Howarth
    0

    Hi Ian,

    I've run a virgin install in Medium Trust on IIS5.1 on Windows XP and I'm sorry to say that I can't reproduce the error that you're having. I'll drop you an email in a little while.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 04, 2010 @ 17:58
    Jamie Howarth
    0

    Hi all,

    This bug was finally resolved. Basically the umbraco.config file in the /data folder requires read/write access. Ian's hosting provider claimed that the username trying to access this file was the ASP.NET username, not the application pool username. It appeared that the hosting provider was using ASP.NET impersonation for running sites in Medium Trust to avoid security access outside the site root, and not actually running default sites using the web.mediumtrust.config file provided by Microsoft.

    In short, don't use ASP.NET impersonation :-)

  • bob baty-barr 1180 posts 1294 karma points MVP
    Jan 05, 2010 @ 04:58
    bob baty-barr
    0

    wow, gotta tell you, this is an AWESOME thread! can you imagine shared windows hosts all around the globe being able to run umbraco?!

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 06, 2010 @ 17:33
    Jamie Howarth
    1

    That was the idea :-) changes are being integrated into Umbraco 4.1 (although I'm trying to convince Niels we should have an Umbraco 4.0.4 - taglined "Full Trust not found" :-D).

    Please vote for this post if you (or the inner geek inside you) think we should have Umbraco 4.0.4!

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jan 06, 2010 @ 20:28
    Niels Hartvig
    1

    Even as funny as it would be and as much as I digg the effort by Benjamin, it would delay v4.1 even further so medium trust support won't see the - official - light of the day before 4.1.

  • Kade 1 post 21 karma points
    Jan 06, 2010 @ 23:41
    Kade
    0

    I just learned about Umbraco a couple of days ago and was very disappointed to find no medium trust support. Very happy to have found this thread! What time frame are we looking at for the 4.1 release Niels?

  • Anonymous 20 posts 31 karma points
    Jan 08, 2010 @ 09:23
    Anonymous
    0

    Hello everybody,

    my ISP (vevida.com) offers the following (quick translation from dutch):

    "The VEVIDA hosting enviroment runs the ASP.NET 3.5 SP1 .NET-Framework in Partial Trust-environment, equal to Medium.
    This means that it is imposible to write or read outside the applicatie folder, overwrite server (-httpRuntime-) configurations, open sockets, etc. This will giva a SecurityException or Configuration Error."

    So my question; is Partial Trust really equal to Medium ? So can I run Umbraco on this platform ?

    Thanks in advance!

    Alfons Roerdink

  • Anonymous 20 posts 31 karma points
    Jan 11, 2010 @ 01:13
    Anonymous
    0

    Hello Benjamin,

    I know that you completely focused on MS Sql, but I tried it with Vista DB.

    The first issue I have is that Content and Media sections are both empty, even after creating a new node/page.

    I tested it by creating a page called "test". After publishing it, Umbraco displayed /test.aspx as "link to document".
    In the CMS the page is still not visible, but at the frontend /test.aspx works perfect....

    Could this be a Vista DB issue?

    Thanks for the good work!

    Regards, Alfons Roerdink

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 11, 2010 @ 09:54
    Douglas Robar
    0

    Hi, Alfons,

    A few things to keep in mind...

    VistaDB does not run under medium trust so you won't be able to use umbraco with vistadb if your site is less than full trust. You'll need either MSSQL or MySQL in medium trust right now.

    Since you got vistadb installed in your 'partial trust' environment it is clear that it is NOT equivalent to medium trust. In true medium trust vistadb wouldn't have installed at all. So that's the answer to your other question.

    Lastly, though the medium trust work is excellent, it is not a released and supported version of umbraco... that will come in umbraco 4.1. Do try it and test it and let us know any issues you encounter. But consider carefully before using it in a production environment.

    cheers,
    doug.

     

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jan 11, 2010 @ 09:59
    Niels Hartvig
    0

    AFAIK vistaDB *does* work in medium trust.

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 11, 2010 @ 10:07
    Douglas Robar
    0

    @Niels, both Benjamin and I have tried it and VistaDB fails to install in medium trust with umbraco 4.0.3. As I recall, it was an error attempting to access temp files.

    cheers,
    doug.

  • Anonymous 20 posts 31 karma points
    Jan 12, 2010 @ 19:05
    Anonymous
    0

    Hi everbody,

    that my content tree is empty is probably caused by the "missing" AJAX 1.0"....(based on http://our.umbraco.org/forum/ourumb-dev-forum/bugs/5343-Content-Tree-empty and some tests)  My ISP provides .Net 3.5 SP1 and o the help page (far away) I found the text line "on our servers software like ODBC.NET (Microsoft.Data.Odbc-namespace), ASP.NET 1.1 (incl. ASP.NET Ajax 1.0 and WSE 3.0) is not available".

    @doug, installing with VistaDB worked, but before I started I removed the VistaDB.vdb3 file...maybe this is working?

    Regard,Alfons

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 13, 2010 @ 15:00
    Jamie Howarth
    0

    Hi Alfons,

    As Doug mentioned, VistaDB will not install in a true Medium Trust environment (this can be simply tested by adding <trust level="Medium" originUrl=".*" /> to your web.config) - however, as we have discovered, some webhosts' implementation of "hosting" does leave a lot to be desired along with a very funny taste in one's mouth!

    Maybe your host doesn't have ASP.NET AJAX 1.0 installed by default, but this should not prevent it from running on a server that doesn't have it installed - you just need the AjaxControlToolkit.dll in your /bin folder and it *should* still run fine (but I have yet to try it on a server that I know for certain doesn't have it installed).

    Best,

    Benjamin

  • Rich Green 2246 posts 4008 karma points
    Jan 25, 2010 @ 18:52
    Rich Green
    0

    Just looking at Rackspace cloud.

    Anyone want to get in touch with Rackspace and update them?

    "Umbraco – Umbraco will not work on Medium Trust.  The application writes to the registry, which is not possible in less than Full Trust.  Umbraco has stated that they will not be modifying their code to remove this dependency."

    http://help.rackspacecloud.com/article.php?id=383

    Doesn't sound very Umbraco like :)

  • Dan 1285 posts 3917 karma points c-trib
    Jan 25, 2010 @ 19:35
    Dan
    0

    Incidentally Rich, the new range of Rackspace cloud servers (which are currently in Beta) will support full trust, so I'm looking forward to that.  Not as much as I'm looking forward to a full release of Umbraco which works in medium trust though ;)

  • Rich Green 2246 posts 4008 karma points
    Jan 26, 2010 @ 13:19
    Rich Green
    0

    Hey Dan,

    I just signed up to Rackspace Sites for a 30 day trial. It's a little expensive I think? However this is just for me so I guess that's why.

    The cloud servers are not available in Windows at the moment right?   Also they are 100% US based, even support, not sure if this is a problem as they are 24/7.

    Really wanted to put a client of mine on them but can see it adding up, not sure how 'Cloud Sites' compares to 'Cloud Servers'? Using SQL Server costs $5 for every 100mb, so suddenly the Umbraco db looks big, which made me think I should use MySql (free on the cloud).

    Hmm, a lot to think about!?

    Rich

  • Paul 6 posts 26 karma points
    Feb 09, 2010 @ 15:58
    Paul
    0

    Awesome work Ben. 

    Does ImageGen work in this Medium trust configuration? Has anyone tried it? If not, will there be another version out to work in Medium trust Doug?

     

    Thanks,

    Paul

  • Jamie Howarth 306 posts 773 karma points c-trib
    Feb 26, 2010 @ 12:34
    Jamie Howarth
    0

    I've installed ImageGen but haven't tested it in detail, will do so though. It should however work in theory.

    Best,

    Benjamin

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Feb 26, 2010 @ 13:00
    Douglas Robar
    0

    ImageGen 2.x does NOT work in medium trust. The high-trust code is soo much faster than the medium-trust code and, since umbraco required high  trust it seemed a fair chioce. Now that medium trust for umbraco is on the horizon we're re-working ImageGen 3 to be medium-trust friendly. If you do happen to be on high trust there will be the option to run the faster code.

    Release will be... as soon as I can... by the 4.1 release if at all possible to coincide with the medium trust support in umbraco 4.1.

    cheers,
    doug.

  • Jamie Howarth 306 posts 773 karma points c-trib
    Feb 26, 2010 @ 14:31
    Jamie Howarth
    0

    @Doug Cool - if you need a hand just holler :-)

    Benjamin

  • Thiago Passos 4 posts 25 karma points
    Sep 05, 2010 @ 11:02
    Thiago Passos
    0

    Hi guys. An update of Rackspace webhosting.

    Recently I signed up for a Cloud site there and they are not working with Full Trust environment, though. Only Medium Trust. Other issue is that the write permission needs to be setup using ASP.NET impersonation.

    I've read a Benjamin's post that says to not use ASP.NET impersonation. Is that just for best practices or it is because won't work?

    Unfortunately, using impersonation is the only way to have write permissions on Rackspace.

    Cheers!

  • kannandesikan 48 posts 68 karma points
    Dec 02, 2011 @ 13:29
    kannandesikan
    0

    Hi

    i got the  below error trying to host a site in go deddy pls help to solve th issues, we have go deddy host and medium trust level,

    pls guide

  • kannandesikan 48 posts 68 karma points
    Dec 02, 2011 @ 13:34
    kannandesikan
    0

    hi,

    i try to host my site in go deddy hosting space , we have shared space and medium trust, if try to run the hosting server

    below i got the error

     

Please Sign in or register to post replies

Write your reply to:

Draft