/** * sapLogout * * @return void * @access private */ public function sapLogout() { if ($this->sapMod != null) { foreach ($this->sapMod as $key => $value) { saprfc_function_free($this->sapMod[$key]); } $this->sapMod = null; } if ($this->sapRfc != null) { saprfc_close($this->sapRfc); $this->sapRfc = null; } }
/** * Close RFC connection to SAP R/3 System * */ function Close() { $this->connType = SAPRFC_CONN_NONE; if (is_array($this->userLogonData)) { unset($this->userLogonData); } $this->userLogonData = false; if (is_array($this->serverReg)) { unset($this->serverReg); } $this->serverReg = false; if (is_array($this->systemInfo)) { unset($this->systemInfo); } $this->systemInfo = false; for ($i = 0; $i < count($this->fceList); $i++) { $this->fceList[$i]->Close(); unset($this->fceList[$i]); } if (is_array($this->fceList)) { unset($this->fceList); } $this->fceList = array(); $this->__InitConnectData(); if ($this->rfc) { @saprfc_close($this->rfc); $this->rfc = false; } }
function rfc_error($operation) { global $trace_fp, $rfc_handle; $tbuf = "\n<== RfcLastErrorEx\n"; $tbud .= sprintf("\nRFC Call/Exception: %s\n", $operation); TRFC_trace($tbuf); $tbuf = saprfc_error(); TRFC_trace($tbuf); $tbuf = "\n<== RfcClose\n"; TRFC_trace($tbuf); saprfc_close ($rfc_handle); if ($trace_fp != false) fclose($trace_fp); exit; }
# 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>"; saprfc_close($rfc);
public function close($fce, $rfc) { saprfc_function_free($fce); saprfc_close($rfc); }
public function __destruct() { saprfc_function_free($this->func); saprfc_close($this->conn); }
function logoff() { if ($this->rfc_conn) { @saprfc_close($this->rfc_conn); } }
/** * @author Manuel Will * @since 2014-05 */ public function closeConnection() { $objConnectionResource = $this->getConnectionResource(); if (!empty($objConnectionResource)) { saprfc_close($objConnectionResource); self::$connectionResource = null; } }
/** * 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; } }