Directory FileSystemInfo file and folder permissions

Discussion in 'ASP .Net Security' started by Brian Watkins, Nov 19, 2003.

  1. I am trying to loop through a directory and place all the folders and files
    into an array. I want to store only the folders and files that the current
    user has access to into the array. Below is some sample code of what I'm
    doing:

    Public Sub ProcessDirectory(byval strPath as string)
    Dim strRootFolder As String = Server.MapPath(strPath)
    Dim dir As New DirectoryInfo(strRootFolder)
    Dim fsi As FileSystemInfo
    For Each fsi In dir.GetFileSystemInfos()
    Try
    If TypeOf fsi Is FileInfo Then 'its a file
    PutFileintoArray(fsi)
    Else 'its a directory
    Dim d As DirectoryInfo = CType( fsi, DirectoryInfo )
    PutDirectoryintoArray(d.name)
    ProcessDirectory(strpath & d.name & "/")
    End If
    Catch

    End Try
    Next fsi

    End Sub

    When the above code runs it stores all the folders and files nicely into the
    array but it is not using the permissions of the client user. It only adds
    the folders and files that everyone has access to. I need to run the above
    code with the client users windows permissions.

    In IIS Directory Security, the Anonymous access is unchecked and Integrated
    Windows Authentication is checked.
    In the Web.config authentication mode="Windows".

    Does anyone know what I'm doing wrong here?
    Brian Watkins, Nov 19, 2003
    #1
    1. Advertising

  2. I found that I needed to set

    <identity impersonate="true" >

    in the Web.config file. Works like a charm now.
    Brian Watkins, Nov 19, 2003
    #2
    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. Jay
    Replies:
    2
    Views:
    744
    Brock Allen
    Apr 5, 2005
  2. Kapil via DotNetMonster.com

    Folder and File Permissions

    Kapil via DotNetMonster.com, Apr 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    428
    Winista
    Apr 10, 2006
  3. Gallagher, Tim (NE)
    Replies:
    1
    Views:
    338
    Adam Jones
    Aug 21, 2006
  4. Replies:
    2
    Views:
    3,620
  5. Adam

    File Upload Folder Permissions

    Adam, Mar 23, 2010, in forum: ASP .Net
    Replies:
    5
    Views:
    2,088
    Alexey Smirnov
    Mar 24, 2010
Loading...

Share This Page