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

Hi All,

I am using apache ldap authentication (not perl ldap)for a perl cgi application. I am able to authenticate users with ldap but dont know how I could get the details of the user who is currently logged in.

Apache should be maintaining details of the user somewhere. Is there any way I could do use perl to get it?
Thanks,
Saura

Replies are listed 'Best First'.
Re: Regarding Perl CGI and Ldap
by jhourcle (Prior) on Feb 19, 2009 at 18:33 UTC

    Check %ENV. There should be the name of the user and domain that they're authenticated in if it's using HTTP basic or digest authentication.

    It's been so long since I've done it that I can't remember what the fields are named.

      Apache sets the login username to the ENV variable REMOTE_USER. Using this I was able to do a LDAP search for the details.

      Thanks everyone.
Re: Regarding Perl CGI and Ldap
by jethro (Monsignor) on Feb 19, 2009 at 17:51 UTC

    You might use Apache::Session to remember details about a session. Apache has no way to tell if some HTTP request comes from the same person that authenticated previously or from a new person. You need session-ids (for example stored in a cookie on the client browser) to connect the independent requests of a session with each other

Re: Regarding Perl CGI and Ldap
by jasonk (Parson) on Feb 20, 2009 at 03:14 UTC

    LDAP authentication is handled simply by binding to the directory as the user you are attempting to authenticate. Other than the uesrname they entered there isn't any other information available about them. If you want to get information about them from the LDAP directory, the usual way to do that is to create a role account that the application can use to connect to the directory and query it for that information.


    www.jasonkohles.com
    We're not surrounded, we're in a target-rich environment!