Results 1 to 3 of 3

Thread: Password Protect a Directory

  1. #1
    Join Date
    Jan 2003

    Password Protect a Directory

    Hello. Can someone give me some help (or point me to some help) on password protecting a directory with asp? I know how to protect single asp pages, but I also have some .pdf and .doc files that need to be protected, so I need to just protect the whole directory I guess. I asked the hosting company to set it up, and they said they could only do one username/password combination, and if I want more than that I need to do it in asp myself. (I have about 20 username/passwords).

    Thank you!

  2. #2
    Join Date
    Jan 2003
    Dundee, Scotland
    I am not sure how to solve your problem but maybe this following will help:

    The File object represents a file and provides properties, which represent the various properties of the actual file. It also provides methods, which let you copy, move and delete files.

    To obtain a File object and examine its properties, use the following steps:
    1. Create a FileSystemObject variable by declaring it as follows:

    Set FSYS = CreateObject(“Scripting.FileSystemObject”)

    2. Use the FSYS variable to obtain an object that represents a specific file:

    Set file = FSYS.GetFile(filename)

    Where filename is the desired file’s path name (c:\Intput\wwwroot\images.image.bmp, for example).

    3. Then access the file’s properties through the file object variable:

    FName = file.Name
    FDate = file.DateCreated
    FSize = file.Size

    You use the Attributes property to read or set a file’s attributes, such as read-only, archive, hidden, and so on). The attributes of a file are numeric values and a file can have multiple attributes. In this case, the file’s attribute is the numeric sum of the values of the individual attributes.


    fileAttibutes = thisFile.Attributes

    The attribute variable can have any of the following values:

    Hidden file = 2
    System file = 4
    Volume = 8
    Directory = 16
    Archive = 32
    Alias = 64
    Compressed = 2048

    To find out whether a file is ready-only, use this statement:

    IF thisFile.Attributes and 1 Then
    ‘The files is Ready-only
    End If

    To delete the file, you must first change the ready-only attribute of the file with a statement like the following one:

    If thisFile.Attributes And 1 Then
    thisFile.Attributes = thisFile.Attributes + 1
    End If

    Normally, when we set a file’s attributes, we don’t reset the existing ones. For example, you many choose to add the hidden attribute from a file that has its ready-only attribute set. To turn on the hidden attribute without affecting the other ones, use a statement such as:

    thisFile.Attributes = thisFile.Attributes + 2

    or you can use this:

    thisFile.Attributes = thisFile.Attributes Or 2

    To remove a specific attribute, first find out wether this attribute is already set, and then subtract its value for the Attributes property’s value. To remove the Hidden attribute, use a structure like the following one:

    If thisFile.Attributes And 2 Then
    thisFile.Attributes = thisFile.Attributes – 2
    End If

    Im sure you can access the Folder attributes using the above method but using this line:

    Set FSYS = CreateObject(“Scripting.FileSystemObject”)
    set ThisFolder = FSYS.GetFolder(FolderName)

    Hope this helps.

    Last edited by Ribeyed; 02-11-2003 at 07:18 AM.

  3. #3
    Join Date
    Jan 2003
    That's great information, but I don't think it really does what I'm looking for. I may end up embedding the pdf files in asp pages and just converting the .doc files to asp. That way I can check for authorized users within the pages. I can't believe there's not some other way of doing this though.

    I'm trying to convert a site that a client had on another server, and they were using .htaccess to protect the directory, but I understand this doesn't work with windows servers.

    Thanks anyway.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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