KRB5NegotiateAuth
PHP Manual

KRB5NegotiateAuth::doAuthentication

(No version information available, might be only in CVS)

KRB5NegotiateAuth::doAuthenticationPerforms HTTP Negotiate authentication

Description

public bool KRB5NegotiateAuth::doAuthentication ( void )

This method performs HTTP Negotiate authentication. It will fetch the provided credentials from the request headers and set the response headers appropriately to perform authentication.

Parameters

This function has no parameters.

Return Values

Returns true when authentication was successful, false otherwise.

Examples

Example #1 KRB5NegotiateAuth::doAuthentication() example

<?php
$auth 
= new KRB5NegotiateAuth('/etc/krb5.keytab');


if(
$auth->doAuthentication()) {
        echo 
'Success - authenticated as ' $auth->getAuthenticatedUser();

        try {
                
$cc = new KRB5CCache();
                
$auth->getDelegatedTicket($cc);
        } catch (
Exception $error) {
                echo 
'No delegated credentials available';
        }
} else {
        if(!empty(
$_SERVER['PHP_AUTH_USER'])) {
                
header('HTTP/1.1 401 Unauthorized');
                
header('WWW-Authenticate: Basic'false);
        } else {
                
// verify basic authentication data
                
echo 'authenticated using BASIC method<br />';
        }
}

?>

See Also


KRB5NegotiateAuth
PHP Manual