ADSI and DirectoryServices Security issue

From: Marcus Müller (marcusmueller_at_gmx.de)
Date: 06/30/03


Date: Mon, 30 Jun 2003 15:13:02 +0200


Hi,

I have a problem using DirectoryServices (ADSI) with ASP.DOT.
The following function returns the mime description of a file extension (a
reference to the "Active DS Type Library" COM object is required):

using System.DirectoryServices;
using System.IO;
private string MimeType(string sFile)
{
    string sExtension = Path.GetExtension(sFile);
    DirectoryEntry cMimeMap = new DirectoryEntry("IIS://LocalHost/MimeMap");
    object[] arMimeMap = (object[])cMimeMap.Invoke("GetEx", "MimeMap");
    foreach(IISOle.IISMimeType cMimeType in arMimeMap)
        if(cMimeType.Extension == sExtension)
            return cMimeType.MimeType;
                return "application/octet-stream";
}

I was only able to get access to the mime map if <identity
impersonate='true'/> was set in the web.config file and IUSR_MACHINE was a
member of the administrator group. These securtiy settings are quite unsafe
and not applicable for a production system.

Hence, does anybody have a solution how to access ADSI without changing the
IIS account security settings or, even better, how to access the IIS mime
map without ADSI ?

Many thanks in advance.

Marcus



Relevant Pages

  • Re: Getting a files mime-type
    ... unknown wrote: ... I'm trying to check the type before processing a bunch of files on disk ... Using a file extension is fast. ... "shared-mime-info is a pure Ruby library for accessing the MIME info ...
    (comp.lang.ruby)
  • Re: PHP bug?!!
    ... image/gif as MIME and text/plain for text files but when I try ... test.jpg it doesn't recognize the MIME type. ... Informations like file extension and content type are sent by the ...
    (comp.lang.php)
  • Re: MimeType
    ... abcd wrote: ... I have not very much experience with SAFEArrays ... information on how to manage MIME via ADSI you can find here: ...
    (microsoft.public.inetserver.iis)