Results 1 to 5 of 5

Thread: Script Runs As Wrong User [Resolved]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718

    Question Script Runs As Wrong User [Resolved]

    In my site, i use the following ASP.NET script to automatically fill a table with the users downloads so that all i have to do to share the files is copy the files into the folder and the script creates the links and does the rest. However, i use Windows security to lockout the files so other users can't access each others files. The problem i have is that the script seems to run as the user NETWORK SERVICE and they have to have permission to list folder contents. To allow my script to work, i have to give this account permissions to see all the files in everybodies folders which means that anyone who knows the username of someone else can see their files. Is there a way to prevent this from happening and force the script to run as the user logged on?

    VB Code:
    1. Dim Username as String = Request.QueryString("username") 'Username of the user to whom's files are to be retrieved
    2.  
    3. Dim URLPath as string = "downloads/users/" & Username & "/files/" 'The path that is appended to the files for the hyperlinks
    4. Dim DirInfo As New DirectoryInfo("...\Downloads\users\" & username & "\files") 'The directory the files are referenced from
    5.  
    6.  
    7. Dim fInfo As FileInfo() = DirInfo.GetFiles
    8. Dim FileName as String 'Stores the file name so that the spaces can be replaced with %20 for hyperlinks
    9. Dim FileSize as Single 'Stores the size of the files so that they can be rounded to two decimal places
    10. Dim CreatedDate as Date 'Stoes the date the file was added i.e. the created date

    And the rest just sorts the data and puts it into a table.
    Last edited by Ideas Man; Apr 11th, 2004 at 11:08 PM.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width