Reading the server mimemap.

Discussion in 'ASP General' started by Anthony Jones, Feb 21, 2006.

  1. Hi people,

    I use the following code to read the server's mimemap and resove a file
    extension to a mime type:-

    Public Function GetMimeType(ByVal Extension)

    Dim oMimeMap
    Dim vntMimeType
    Dim avntMap()

    Set oMimeMap = GetObject("IIS://LocalHost/MimeMap")

    If Left(Extension, 1) <> "." Then Extension = "." & Extension

    avntMap() = oMimeMap.MimeMap

    For Each vntMimeType In avntMap
    If vntMimeType.Extension = Extension Then
    GetMimeType = vntMimeType.MimeType
    Exit For
    End If
    Next

    If GetMimeType = "" Then GetMimeType = "application/octet-stream"

    End Function

    Problem is the GetObject requires the account underwhich this code runs to
    be an Operator in WWW Service Master properties. It's undesirable to add
    IUSR or IWAM as an operator.

    I only want to read this information not edit. Is there any other way I can
    resolve a file extension to a mime type in ASP code without elevated
    priviledges?

    Ta,

    Anthony.
    Anthony Jones, Feb 21, 2006
    #1
    1. Advertising

  2. Anthony Jones

    Per Guest

    Hi,

    I have the same problem!
    How can I set read permissions for the IUSR_MACHINENAME to retrieve the
    "IIS://LocalHost/MimeMap" values.
    Is there another way to retrieve these values without administrative rights.


    Regards,

    Per Dunberg


    "Anthony Jones" wrote:

    > Hi people,
    >
    > I use the following code to read the server's mimemap and resove a file
    > extension to a mime type:-
    >
    > Public Function GetMimeType(ByVal Extension)
    >
    > Dim oMimeMap
    > Dim vntMimeType
    > Dim avntMap()
    >
    > Set oMimeMap = GetObject("IIS://LocalHost/MimeMap")
    >
    > If Left(Extension, 1) <> "." Then Extension = "." & Extension
    >
    > avntMap() = oMimeMap.MimeMap
    >
    > For Each vntMimeType In avntMap
    > If vntMimeType.Extension = Extension Then
    > GetMimeType = vntMimeType.MimeType
    > Exit For
    > End If
    > Next
    >
    > If GetMimeType = "" Then GetMimeType = "application/octet-stream"
    >
    > End Function
    >
    > Problem is the GetObject requires the account underwhich this code runs to
    > be an Operator in WWW Service Master properties. It's undesirable to add
    > IUSR or IWAM as an operator.
    >
    > I only want to read this information not edit. Is there any other way I can
    > resolve a file extension to a mime type in ASP code without elevated
    > priviledges?
    >
    > Ta,
    >
    > Anthony.
    >
    >
    >
    Per, Mar 14, 2006
    #2
    1. Advertising

  3. Anthony Jones

    aa Guest

    a
    ---
    Posted via DotNetSlackers.com
    aa, Oct 18, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darrel
    Replies:
    3
    Views:
    673
    Kevin Spencer
    Nov 11, 2004
  2. Wael Soliman

    ASP.NET Reading problem (reading .xls)

    Wael Soliman, Jan 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,790
    =?Utf-8?B?dmluYXk=?=
    Jan 3, 2005
  3. -
    Replies:
    2
    Views:
    397
    Alan Krueger
    Jul 29, 2005
  4. Replies:
    0
    Views:
    783
  5. Karim Ali

    Reading a file and resuming reading.

    Karim Ali, May 25, 2007, in forum: Python
    Replies:
    2
    Views:
    372
    Hrvoje Niksic
    May 25, 2007
Loading...

Share This Page