#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Christchurch New Zealand
    Posts
    0
    Rep Power
    0
    I am running apache for windows and active perl on a win 98 machine.
    When I create a restricted directory in the apache httpd.conf file, the browser asks for a user name and password as it should.
    I can set up the user names and passwords using htpasswd.exe(an executable that sits in my apache directory) This runs in a Dos shell. This all works nicely.
    Now I want to be able to add users to the password file via a html form and a perl script. Ican do this by a number of means but I need to know what function??/module??/?? I use so that Apache recognises the new users and passwords. Is it just htpasswd/ If so how?
    I am a relative novice and don't need a super sophisticated solution.I have got more confused the more I read. A simple solution or a point in the right direction would be appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    Well, if you want to tacle some real stuff, I suggest using the perl's builtin crypt() function (perldoc -f crypt from the DOS prompt to see some info about it). As I also recall, there was a thread I started on the sam topic here, so you should try to search for it.

    But if you don't want to get this involved then just do the following from your perl script:
    Code:
    $command = "htpasswd -b path/to/your/password/file";
    $username = $FORM{"username}; #Or however do you parse the parameters
    $pass = $FORM{"pass"};
    
    if (!system($command,$username,$pass)){
        #everything went OK
    }else{
        #something has gone wrong
    }
    The above will call the htpasswd utility and supply your arguments to it. Since the command has the -b switch it will ask for a password from the command line, so everything will be fine.

    Just to warn you, though, this is NOT very secure...

IMN logo majestic logo threadwatch logo seochat tools logo