Une application peut connaître l'utilisateur connecté en utilisant :
Pour obtenir plus d'information sur l'utilisateur (nom, adresse de courriel, etc...), il faut lire les en-têtes HTTP.
Exemples avec un en-tête configuré nommé 'Auth-User':
print "Connected user: ".$ENV{HTTP_AUTH_USER};
print "Connected user: ".$_SERVER["HTTP_AUTH_USER"];
Using this feature, you don't have to use virtual host protection: protection is embedded in Lemonldap::NG::Handler::CGI.
The protection parameter must be set when calling the new() method:
none
: no protectionauthenticate
: check authentication but do not manage authorizationmanager
: rely on virtual host configuration in Managerrule: xxx
: apply a specific rule Exemple :
my $cgi = new CGI; ...
my $cgi = Lemonldap::NG::Handler::CGI->new ({ protection => 'authenticate' }); print $cgi->header; print $cgi->start_html; ...
On peut ensuite accéder aux données de l'utilisateur
# Obtenir des attributs (ou macros) my $cn = $cgi->user->{cn} # Tester si l'utilisateur est membre d'un groupe Lemonldap::NG (ou d'un groupe LDAP translaté) if( $cgi->group('admin') ) { # code html spécial pour les administrateurs } else { # autre code HTML }