Exemple #1
0
# $Id: test_sso.php,v 1.1 2005/12/18 16:26:23 koucky Exp $
# Prerequisite:
#    Profile parameters: login/create_sso2_ticket = 1
#                        login/accept_sso2_ticket = 1
#    Transaction SSO2 - Administration logon ticket
#
# The first logon to SAP using username and password, request for ticket GETOSS2 = 1
# Please change logon parameters for your system
$login = array("ASHOST" => "<hostname>", "SYSNR" => "00", "CLIENT" => "<client>", "USER" => "<username>", "PASSWD" => "<password>", "GETSSO2" => "1");
$rfc = saprfc_open($login);
if (!$rfc) {
    echo "RFC connection failed";
    exit;
}
# Get SSO ticket
$ticket = saprfc_get_ticket($rfc);
saprfc_close($rfc);
if ($ticket) {
    echo "SSO2 ticket = " . $ticket . "<br>";
}
# The second logon to SAP using SSO2 ticket
unset($login["PASSWD"]);
unset($login["USER"]);
unset($login["GETSS02"]);
$login["MYSAPSSO2"] = $ticket;
$rfc = saprfc_open($login);
if (!$rfc) {
    echo "SSO2 RFC connection failed";
    exit;
}
echo "SSO2 OK<br>";
Exemple #2
-1
 /**
  * Performs username and password check
  *
  * @param string Username
  * @param string Password
  * @return boolean TRUE on success (valid user), FALSE otherwise
  */
 function fetchData($username, $password)
 {
     $this->log('Auth_Container_SAP::fetchData() called.', AUTH_LOG_DEBUG);
     $connection_options = $this->options;
     $connection_options['USER'] = $username;
     $connection_options['PASSWD'] = $password;
     $rfc = saprfc_open($connection_options);
     if (!$rfc) {
         $message = "Couldn't connect to the SAP system.";
         $error = $this->getError();
         if ($error['message']) {
             $message .= ': ' . $error['message'];
         }
         PEAR::raiseError($message, null, null, null, @$erorr['all']);
         return false;
     } else {
         if (!empty($this->options['GETSSO2'])) {
             $this->log('Attempting to retrieve SSO2 ticket.', AUTH_LOG_DEBUG);
             if ($ticket = @saprfc_get_ticket($rfc)) {
                 $this->options['MYSAPSSO2'] = $ticket;
                 unset($this->options['GETSSO2']);
                 $this->_auth_obj->setAuthData('sap', $this->options);
             } else {
                 PEAR::raiseError("SSO ticket retrieval failed");
             }
         }
         @saprfc_close($rfc);
         return true;
     }
 }