Re: Windows Impersonation in ASP.NET

Pierre posted an entry bout impersonation in ASP.NET szenarios. [Pierre]There are several scenario where you have to use the impersonation in ASP.NET. Consider, for example, you have to save and load files from a network share (file server). In that case, if the web site accept anonymous authentications, you have to impersonate a windows user who has enought privileges to access to that resource. You have three choices (I guess): Elevate the ASP.NET process identity - worse case since you could compromise the whole site security Impersonate a windows user during the single call (http://blogs.msdn.com/shawnfa/archive/2005/03/22/400749.aspx) Demand the task to a COM+ server application I think that the last is the best since we have more security and maintenance control[...] I agree with him that "Demand the task to a COM+ server application" is the best way of the three he listed. But for me impersonation it is still a don't. By the way i wanted to post this as a comment but "Comments on this post are closed". Yes this is some criticism on weblogs.asp.net :-) ... So here my opinion as post in my blog: Avoid impersonation! If you need to "redirect a binary that is located on a different box than the webserver to the client" utilize another IIS on the 2nd machine or write a service that returns the binary data.  

Using IFused with the FCKEditor

Miroslaw Maslyk has sent this small tutorial on how to use iFused with the FCKEditor. Thank you very much Miro ;-) 1. Rename file FCKeditor\editor\dialog\fck_image.html to fck_image.aspx. 2. On the top this file (fck_image.aspx) add this code: <%@ Page Language="C#" %><%@ Register TagPrefix="Uploader"  namespace="StaticDust.Web.UI.Controls"  assembly="StaticDust.Web.UI.Controls.UploadDialog" %><script runat="server">protected void Page_Load(Object source, EventArgs e) {    StaticDust.Web.UI.Controls.UploadDialogButton _u =      new StaticDust.Web.UI.Controls.UploadDialogButton();    _u.UploadDirectory = "~/images";    _u.ReturnFunction = "SetUrl()";    btnBrowse.Attributes["OnClick"] =      "javascript:" + _u.JavascriptLink; } </script> 3. Find btnBrowse input html tag , add runat="server" attribute and close tag (/>) 4. Replace in files FCKEditor\FCKeditor\editor\js\fckeditorcode_ie_2.js and fckeditorcode_gecko_2.js all fck_image.html sentence to fck_image.aspx

@BASTA! #1

Yesterday I arrived in Frankfurt with a delay of 2 hours (thanks to the Deutsche Bahn). Monday is Workshop day and so I just sat arround and did the same stuff that I would normally do in the office. I'm currently working on an ASP.NET project that uses v. 1.1 but will be converted to 2.0 with it's "Go-Live". So I need to make sure that I don't do things that will stand in the way in the next version. Here are a few questions I'm currently asking myself: Do i like the idea to save the properties of the Profile class in a ntext database column with the length of 6000? Will i accept that i can only user MemberShip with MediumTrust or higher? In germany we say: "Kommt Zeit, kommt Rat".

The UploadDialogControl v. 2.3.1.10088 and beyond

I currently working again on iFused (Internet File Upload Select and image Editing Dialog). Yesterday i released the version 2.3.1.10088: support for "~" as palceholder for the application path code optimization performance optimization I have a lot of things to do on based on the wishlist forum at staticdust and loads of mail in my inbox. This is what i plan to catch until 1st. of february: Use physical path outside of the application root as UploadDirectory Database as source for files and directorys

C# Image 2 ASCII

What i really like about the days between x-mas and new year is that you have time for things that you usually don't have time for. The stroy: I love my girlfriend. I likle C# and I like asciiart. So it happend that she showed me some ascii's. I asked myself if somebody has written some image to ascii in C#. I googled but found nothing. I did some image manipulation stuff for the company before x-mas and so I builded a basic image to ascii conversion library in C#.http://www.lennybacon.com/image2ascii/You can grab the source at : http://www.codeproject.com/aspnet/ascii_art_with_c_.asp

NDoc Macro again

Something usefull i posted in my old blog and promised Christian and Günther to post it again... #Region "NDoc()"    Sub NDoc()        Dim nDocPath As String = "C:\Program files\NDoc\bin\.net-1.1\"        Dim objProj As Object()        Dim proj As Project        'Get Project        objProj = DTE.ActiveSolutionProjects        If objProj.Length = 0 Then            Exit Sub        End If        proj = DTE.ActiveSolutionProjects(0)        If (proj.ConfigurationManager.ActiveConfiguration.ConfigurationName = "Debug") Then            MsgBox("You cannot run this Macro in the Debug-configuration." & vbCrLf & _            "Switch to ""Realease"", build the project and run this Macro again.")            Exit Sub        End If        proj.ConfigurationManager.ActiveConfiguration.Properties.Item("DocumentationFile").Value =            proj.Properties.Item("AssemblyName").Value() & ".xml"        proj.Save()        Dim XmlString As String = "<project>" & vbCrLf & _            "    <assemblies>" & vbCrLf & _            "        <assembly location=""" & proj.Properties.Item("FullPath").Value() & _            "bin\Release\" & proj.Properties.Item("OutputFileName").Value() & """ documentation=""" & _            proj.Properties.Item("FullPath").Value() & "bin\Release\" & _            proj.Properties.Item("AssemblyName").Value() & ".xml"" />" & vbCrLf & _            "    </assemblies>" & vbCrLf & _            "    <namespaces>" & vbCrLf & _            "    </namespaces>" & vbCrLf & _            "    <documenters>" & vbCrLf & _            "        <documenter name=""MSDN"">" & vbCrLf & _            "            <property name=""OutputDirectory"" value=""" & _            proj.Properties.Item("FullPath").Value() & "doc\"" />" & vbCrLf & _            "            <property name=""HtmlHelpName"" value=""" & _            proj.Properties.Item("AssemblyName").Value() & """ />" & vbCrLf & _            "            <property name=""IncludeFavorites"" value=""True"" />" & vbCrLf & _            "            <property name=""Title"" value=""" & _            proj.Properties.Item("AssemblyName").Value() & _            """ />" & vbCrLf & _            "            <property name=""SplitTOCs"" value=""False"" />" & vbCrLf & _            "            <property name=""DefaulTOC"" value="""" />" & vbCrLf & _            "            <property name=""IncludeHierarchy"" value=""True"" />" & vbCrLf & _            "            <property name=""ShowVisualBasic"" value=""True"" />" & vbCrLf & _            "            <property name=""RootPageContainsNamespaces"" value=""True"" />" & vbCrLf & _            "            <property name=""SortTOCByNamespace"" value=""True"" />" & vbCrLf & _            "            <property name=""OutputTarget"" value=""HtmlHelpAndWeb"" />" & vbCrLf & _            "            <property name=""HeaderHtml"" value="""" />" & vbCrLf & _            "            <property name=""FooterHtml"" value=""Copyright © " & Year(Now) & _            " &lt;a href=http://www." & _            proj.Properties.Item("AssemblyName").Value().Split(".".ToCharArray)(0) & _            ".com&gt;" & _            proj.Properties.Item("AssemblyName").Value().Split(".".ToCharArray)(0) & _            " &lt;/a&gt; - all rights reserved."" />" & vbCrLf & _            "            <property name=""FilesToInclude"" value="""" />" & vbCrLf & _            "            <property name=""LinkToSdkDocVersion"" value=""MsdnOnline"" />" & vbCrLf & _            "            <property name=""ShowMissingSummaries"" value=""True"" />" & vbCrLf & _            "            <property name=""ShowMissingRemarks"" value=""False"" />" & vbCrLf & _            "            <property name=""ShowMissingParams"" value=""True"" />" & vbCrLf & _            "            <property name=""ShowMissingReturns"" value=""True"" />" & vbCrLf & _            "            <property name=""ShowMissingValues"" value=""True"" />" & vbCrLf & _            "            <property name=""DocumentInternals"" value=""False"" />" & vbCrLf & _            "            <property name=""DocumentProtected"" value=""True"" />" & vbCrLf & _            "            <property name=""DocumentPrivates"" value=""False"" />" & vbCrLf & _            "            <property name=""DocumentProtectedInternalAsProtected"" value=""False"" />" & _            vbCrLf & _            "            <property name=""DocumentEmptyNamespaces"" value=""False"" />" & vbCrLf & _            "            <property name=""IncludeAssemblyVersion"" value=""False"" />" & vbCrLf & _            "            <property name=""CopyrightText"" value="""" />" & vbCrLf & _            "            <property name=""CopyrightHref"" value="""" />" & vbCrLf & _            "            <property name=""ReferencesPath"" value="""" />" & vbCrLf & _            "            <property name=""SkipNamespacesWithoutSummaries"" value=""False"" />" & _            vbCrLf & _            "            <property name=""UseNamespaceDocSummaries"" value=""False"" />" & vbCrLf & _            "            <property name=""AutoPropertyBackerSummaries"" value=""False"" />" & vbCrLf & _            "            <property name=""AutoDocumentConstructors"" value=""True"" />" & vbCrLf & _            "            <property name=""DocumentAttributes"" value=""True"" />" & vbCrLf & _            "            <property name=""ShowTypeIdInAttributes"" value=""True"" />" & vbCrLf & _            "            <property name=""DocumentedAttributes"" value="""" />" & vbCrLf & _            "            <property name=""GetExternalSummaries"" value=""True"" />" & vbCrLf & _            "            <property name=""EditorBrowsableFilter"" value=""Off"" />" & vbCrLf & _            "            <property name=""UseNDocXmlFile"" value="""" />" & vbCrLf & _            "        </documenter>" & vbCrLf & _            "    </documenters>" & vbCrLf & _            "</project>"        Dim FileWriter As System.IO.StreamWriter        FileWriter = System.IO.File.CreateText(proj.Properties.Item("FullPath").Value() & _        proj.Properties.Item("AssemblyName").Value() & ".ndoc")        FileWriter.WriteLine(XmlString)        FileWriter.Close()        proj.ProjectItems.AddFromFile(proj.Properties.Item("FullPath").Value() & _        proj.Properties.Item("AssemblyName").Value() & ".ndoc")        proj.Save()        If System.IO.Directory.Exists(proj.Properties.Item("FullPath").Value & "\doc\") = False Then            System.IO.Directory.CreateDirectory(proj.Properties.Item("FullPath").Value & "\doc\")        End If        Dim hasDocDir As Boolean = False        For Each pitem As EnvDTE.ProjectItem In proj.ProjectItems            If pitem.Name = "doc" Then                hasDocDir = True            End If        Next        If hasDocDir = False Then            proj.ProjectItems.AddFolder("doc")            proj.Save()        End If        If System.IO.File.Exists(proj.Properties.Item("FullPath").Value & "\doc\" & proj.Properties.Item("AssemblyName").Value & ".chm") = False Then            Dim chmWriter As System.IO.StreamWriter =                 System.IO.File.CreateText(proj.Properties.Item("FullPath").Value() & "\doc\" & _            proj.Properties.Item("AssemblyName").Value() & ".chm")            chmWriter.WriteLine("")            chmWriter.Close()        End If        proj.ProjectItems.AddFromFile(proj.Properties.Item("FullPath").Value() & "\doc\" & proj.Properties.Item("AssemblyName").Value() & ".chm")        proj.Save()        If proj.Properties.Item("PostBuildEvent").Value = "" Then            proj.Properties.Item("PostBuildEvent").Value = """" & nDocPath & _                 "NDocConsole.exe"" -documenter=MSDN -project=""$(ProjectDir)" & _                 proj.Properties.Item("AssemblyName").Value() & ".ndoc"" -verbose" & vbCrLf & _                 "copy $(ProjectDir)doc\" & proj.Properties.Item("AssemblyName").Value() & _                 ".chm $(TargetDir)"        Else            Dim existing As String = ("" & proj.Properties.Item("PostBuildEvent").Value)            Dim exArr As String() = existing.Split(vbCrLf)            existing = ""            Dim y As Integer            For y = 0 To (exArr.Length - 1)                If exArr(y).IndexOf(nDocPath) = -1 And exArr(y).IndexOf(".chm") = -1 Then                    existing = existing & vbCr & exArr(y)                End If            Next            existing = nDocPath & _                 "NDocConsole.exe -documenter=MSDN -project=""$(ProjectDir)" & _                 proj.Properties.Item("AssemblyName").Value() & ".ndoc"" -verbose" & vbCrLf & _                 "copy $(ProjectDir)doc\" & proj.Properties.Item("AssemblyName").Value() & _                 ".chm $(TargetDir)" & _                 existing            proj.Properties.Item("PostBuildEvent").Value = existing        End If        proj.Save()        MsgBox("The file """ & proj.Properties.Item("AssemblyName").Value() & _            ".ndoc"" has been added to the project." & vbCrLf & _            "NDoc was registred as PostBuildEvent.")    End Sub#End Region

Another template based solution with ASP.NET 1.1

In the past weeks i have looked at several template based solutions for ASP.NET 1.1, because i can't wait for .NET 2.0. Region MasterPages and it's variations all around the webNo WYSIWYG/VS.NET support - No solution for me. Masterpages reinventedNice try, but i don't want to add so much lines to the code behind. I also realized SiteMesh.NET (http://joe.truemesh.com/blog/000275.html - hey Joe fix that damn JS error!!!), but i don't like that approach. So i decided to think about other concepts and wrote something that solves following for me: MasterPage WYSIWYG in VS.NET CodeBehind Other pages WYSIWYG in VS.NET CodeBehind ... with one line of code in the client pages. I'll talk about my solution on the VFL-NiederRhein UG Meeting in november or december. So if you are interested keep an eye open.