Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Querying IISMimeMap .. Access is denied .. HELP!

Reply
Thread Tools

Querying IISMimeMap .. Access is denied .. HELP!

 
 
Marlon
Guest
Posts: n/a
 
      07-22-2004
Code posted below ( I am not sure which group to post to, but I need help)

I wrote a Windows Form Application to query the IIS MimeMap on the localhost
which worked fine.

I ran the same code in asp.net and got "Access is Denied" exception.

What is the least permissions set I should grant the aspnet account to avoid
the exception.
Or any other suggest would be fine

Thanks.

Private Function CacheMimeMaps() As Specialized.StringDictionary

#If DEBUG Then

Dim starttime As DateTime = DateTime.Now

#End If

Dim entry As DirectoryServices.DirectoryEntry

Try

Dim mimeMaps As New Specialized.StringDictionary

entry = New DirectoryServices.DirectoryEntry("IIS://localhost/MimeMap")

Dim pvcMimeMap As DirectoryServices.PropertyValueCollection =
entry.Properties("MimeMap")

For Each o As Object In pvcMimeMap

Dim mt As IISOle.IISMimeType = CType(o, IISOle.IISMimeType)

mimeMaps.Add(mt.Extension, mt.MimeType)

#If DEBUG Then

Console.WriteLine("{0} = {1}", mt.Extension, mt.MimeType)

#End If

Next

' MimeMaps were found

If mimeMaps.Count > 0 Then

Me.Cache.Add(MIMEMAP, mimeMaps, Nothing, Cache.NoAbsoluteExpiration,
Cache.NoSlidingExpiration, Caching.CacheItemPriority.Low, Nothing)

Return mimeMaps

End If

pvcMimeMap = Nothing

Catch ex As Exception ' do nothing

Stop

Finally

#If DEBUG Then

Dim endtime As DateTime = DateTime.Now

Console.WriteLine(starttime.ToString() & "." &
starttime.Millisecond.ToString())

Console.WriteLine(endtime.ToString() & "." & endtime.Millisecond.ToString())

#End If

If (Not entry Is Nothing) Then

entry.Close()

entry.Dispose()

End If

End Try

End Function




 
Reply With Quote
 
 
 
 
Egbert Nierop \(MVP for IIS\)
Guest
Posts: n/a
 
      07-22-2004
Access is denied because only admins can run that code.
By default, your code runs under a process for IIS that has no
administrative rights.

--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm

"Marlon" <(E-Mail Removed)> wrote in message
news:%23Nv%(E-Mail Removed)...
> Code posted below ( I am not sure which group to post to, but I need
> help)
>
> I wrote a Windows Form Application to query the IIS MimeMap on the
> localhost
> which worked fine.
>
> I ran the same code in asp.net and got "Access is Denied" exception.
>
> What is the least permissions set I should grant the aspnet account to
> avoid
> the exception.
> Or any other suggest would be fine
>
> Thanks.
>
> Private Function CacheMimeMaps() As Specialized.StringDictionary
>
> #If DEBUG Then
>
> Dim starttime As DateTime = DateTime.Now
>
> #End If
>
> Dim entry As DirectoryServices.DirectoryEntry
>
> Try
>
> Dim mimeMaps As New Specialized.StringDictionary
>
> entry = New DirectoryServices.DirectoryEntry("IIS://localhost/MimeMap")
>
> Dim pvcMimeMap As DirectoryServices.PropertyValueCollection =
> entry.Properties("MimeMap")
>
> For Each o As Object In pvcMimeMap
>
> Dim mt As IISOle.IISMimeType = CType(o, IISOle.IISMimeType)
>
> mimeMaps.Add(mt.Extension, mt.MimeType)
>
> #If DEBUG Then
>
> Console.WriteLine("{0} = {1}", mt.Extension, mt.MimeType)
>
> #End If
>
> Next
>
> ' MimeMaps were found
>
> If mimeMaps.Count > 0 Then
>
> Me.Cache.Add(MIMEMAP, mimeMaps, Nothing, Cache.NoAbsoluteExpiration,
> Cache.NoSlidingExpiration, Caching.CacheItemPriority.Low, Nothing)
>
> Return mimeMaps
>
> End If
>
> pvcMimeMap = Nothing
>
> Catch ex As Exception ' do nothing
>
> Stop
>
> Finally
>
> #If DEBUG Then
>
> Dim endtime As DateTime = DateTime.Now
>
> Console.WriteLine(starttime.ToString() & "." &
> starttime.Millisecond.ToString())
>
> Console.WriteLine(endtime.ToString() & "." &
> endtime.Millisecond.ToString())
>
> #End If
>
> If (Not entry Is Nothing) Then
>
> entry.Close()
>
> entry.Dispose()
>
> End If
>
> End Try
>
> End Function
>
>
>
>


 
Reply With Quote
 
 
 
 
Roger Bavaud
Guest
Posts: n/a
 
      07-22-2004
You can try to work with Impersonation
http://support.microsoft.com/default...b;en-us;306158

Regards
Roger


"Marlon" <(E-Mail Removed)> wrote in message
news:%23Nv%(E-Mail Removed)...
> Code posted below ( I am not sure which group to post to, but I need

help)
>
> I wrote a Windows Form Application to query the IIS MimeMap on the

localhost
> which worked fine.
>
> I ran the same code in asp.net and got "Access is Denied" exception.
>
> What is the least permissions set I should grant the aspnet account to

avoid
> the exception.
> Or any other suggest would be fine
>
> Thanks.
>
> Private Function CacheMimeMaps() As Specialized.StringDictionary
>
> #If DEBUG Then
>
> Dim starttime As DateTime = DateTime.Now
>
> #End If
>
> Dim entry As DirectoryServices.DirectoryEntry
>
> Try
>
> Dim mimeMaps As New Specialized.StringDictionary
>
> entry = New DirectoryServices.DirectoryEntry("IIS://localhost/MimeMap")
>
> Dim pvcMimeMap As DirectoryServices.PropertyValueCollection =
> entry.Properties("MimeMap")
>
> For Each o As Object In pvcMimeMap
>
> Dim mt As IISOle.IISMimeType = CType(o, IISOle.IISMimeType)
>
> mimeMaps.Add(mt.Extension, mt.MimeType)
>
> #If DEBUG Then
>
> Console.WriteLine("{0} = {1}", mt.Extension, mt.MimeType)
>
> #End If
>
> Next
>
> ' MimeMaps were found
>
> If mimeMaps.Count > 0 Then
>
> Me.Cache.Add(MIMEMAP, mimeMaps, Nothing, Cache.NoAbsoluteExpiration,
> Cache.NoSlidingExpiration, Caching.CacheItemPriority.Low, Nothing)
>
> Return mimeMaps
>
> End If
>
> pvcMimeMap = Nothing
>
> Catch ex As Exception ' do nothing
>
> Stop
>
> Finally
>
> #If DEBUG Then
>
> Dim endtime As DateTime = DateTime.Now
>
> Console.WriteLine(starttime.ToString() & "." &
> starttime.Millisecond.ToString())
>
> Console.WriteLine(endtime.ToString() & "." &

endtime.Millisecond.ToString())
>
> #End If
>
> If (Not entry Is Nothing) Then
>
> entry.Close()
>
> entry.Dispose()
>
> End If
>
> End Try
>
> End Function
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
403 Forbidden: You were denied access because: Access denied by access control list Southern Kiwi NZ Computing 6 03-19-2006 05:19 AM
Problem on querying Access link table in ASP page tabonni ASP General 1 10-14-2004 01:29 PM
Querying IISMimeMap .. Access is denied .. HELP! Marlon ASP General 1 07-22-2004 06:07 PM
Querying IISMimeMap .. Access is Denied .. HELP!! Marlon ASP .Net 0 07-22-2004 01:46 PM



Advertisments