outcast has asked for the wisdom of the Perl Monks concerning the following question:

is there away to query the server or the user web broswer using a cgi script written in perl to see what group they are in?

Replies are listed 'Best First'.
Re: .htaccess and cgi
by BBQ (Curate) on Apr 23, 2000 at 03:35 UTC
    That's a big "it depends" question...
    While it might be easy to figure out if a user is in a certain group by checking the permissions' files, you'd have to check your httpd.conf to see what kind of log format you are using. I'm positive that you can set your log to a combined format that will retain the user accessing a specific resource (by using the authuser token on the CLF (common log format)), but on my servers I only log custom access and errors.

    You might want to check out the Module mod_log_config page... HTH!

    #!/home/bbq/bin/perl
    # Trust no1!
RE: .htaccess and cgi
by chromatic (Archbishop) on Apr 23, 2000 at 08:02 UTC
    The $< variable holds the real user ID of the process and the $> holds the effective UID. If you want to know the user id for a script you're writing, use those variables.

    I think this is an XYZ Question... perhaps you could tell us what you're trying to accomplish in general?

Re: .htaccess and cgi
by httptech (Chaplain) on Apr 23, 2000 at 04:52 UTC
    You'd need to parse the .htgroup file directly probably. The browser can't give you that information, because it doesn't know. The webserver won't set it, because the same user may be in several different groups.

    Maybe you could describe exactly what you need the script to do overall; there may be a better way of going about setting up your .htaccess structure so that you may not even need the script to know the group.

Re: .htaccess and cgi
by httptech (Chaplain) on Apr 24, 2000 at 15:20 UTC
    If you're going to have users with different levels of access, you probably would want to put that info into a database. By using a module such as mod_auth_db, mod_auth_dbm, mod_auth_mysql, etc, Apache can get the passwords from your database for the connecting usernames and handle the authentication.

    Once they have authenticated, your CGI script can access the username from the $ENV{'REMOTE_USER'} variable and then check the database to get the group/access level of that user.

Re: .htaccess and cgi
by outcast (Monk) on Apr 23, 2000 at 05:56 UTC
    thanks guys
Re: .htaccess and cgi
by outcast (Monk) on Apr 24, 2000 at 01:04 UTC
    i am trying to figure the best of setting different levels of user access on a web page with .htaccess and perl cgi.