Monthly Archive for July, 2005

.NET 2.0 makes it easy to handle ACLs

.NET Framework 2.0 ships with a security library which now allows to comfortably read out Access Control Lists (ACLs) of file system and windows registry. I tryed it out and was impressed how easy it is. See the following code, which prints permissions for a directory.

using System;
using System.Security.AccessControl;
using System.Security.Principal;
using System.IO;

namespace AclTestTool
{
  class Program
  {
    static void Main(string[] args)
    {
      for (int i = 0; i < args.Length; i++)
        ReadDirectorySecurity(args[i]);
    }

    static void ReadDirectorySecurity(string sDirName)
    {
      Console.WriteLine("Directory Security for '" +
        sDirName + "'");
      DirectoryInfo dirInfo = new DirectoryInfo(sDirName);
      DirectorySecurity dirSec = dirInfo.GetAccessControl();
      AuthorizationRuleCollection authRuleColl =
        dirSec.GetAccessRules(true, false,
        typeof(SecurityIdentifier));

      foreach (AuthorizationRule authRule in authRuleColl)
      {
        FileSystemAccessRule accessRule =
          (FileSystemAccessRule)authRule;
        NTAccount ntAccount = (NTAccount)
          authRule.IdentityReference.Translate(
          typeof(NTAccount));
        Console.WriteLine("{0} (SID={1}): {2} = {3}",
          ntAccount.Value, accessRule.IdentityReference,
          accessRule.FileSystemRights,
          accessRule.AccessControlType);
      }
    }
  }
}

Also check out this!

Debugging IIS

Recently I had to debug a ISAPI extension on IIS 6 which threw some really strange error. Normaly I use therefore Visual Studio, because it’s really comfortable. But for this that didn’t work.

So I ended up using WinDbg which I integrated in the startup of IIS.

Two interesting articles about this:
Working with WinDbg
Debugging IIS

A small batch, which inserts WinDbg in the start-up of IIS 6:

@echo off
REG ADD "HKLM\Software\Microsoft\Windows NT\
  CurrentVersion\Image File Execution Options\w3wp.exe"
  /v Debugger /t REG_SZ /d "ntsd.exe -g -G" /f
SC CONFIG W3SVC type= share type= interact
NET STOP W3SVC
NET START W3SVC

Integrated photo gallery

Now I’ve integrated my photo gallery into my homepage. That’s really cool - thanks to the TEXX plugin :-)

[cpg_album-rand:4,1]