require "lib/SAP/Rfc"
SAP::Rfc.useCache = false
# Establish first connection using a X.509 Certificate
rfc = SAP::Rfc.new(
:ashost => "zappod.csw.local",
:sysnr => 00,
:lang => "EN",
:client => "800",
:x509cert => "Base64 Encoded Certificate in one line",
:snc_mode => 1,
:snc_qop => 3,
:snc_myname => "p:CN=RFC, OU=IT, O=CSW, C=DE",
:snc_partnername => "p:CN=IDS, OU=IT, O=CSW, C=DE",
:snc_lib => "/usr/sap/IDS/SYS/exe/run/libsapcrypto.so",
:trace => 0
)
# get the connection ID
puts "Connection id: " + rfc.connection.to_s
# test the connection
puts "Are we connected: " + rfc.is_connected().to_s
# look up the interface definition for SUSR_CHECK_LOGON_DATA
irep = rfc.discover("SUSR_CHECK_LOGON_DATA")
# Set the Import Parameters required for external authentication
irep.AUTH_METHOD.value = "E"
irep.AUTH_DATA.value = 'SITECO\G.WOLF'
irep.EXTID_TYPE.value = "NT"
rfc.call(irep)
# What User have we logged in to?
puts "USER_ID: " + irep.USER_ID.value.to_s
# Establish a second connection with Ticked from "SUSR_CHECK_LOGON_DATA"
call ticket = irep.TICKET.value.to_s
rfc2 = SAP::Rfc.new(
:ashost => "zappod.csw.local",
:sysnr => 00,
:lang => "EN",
:client => "800",
:mysapsso2 => ticket,
:trace => 1
)
# get the connection ID
puts "Connection id: " + rfc2.connection.to_s
# test the connection
puts "Are we connected: " + rfc2.is_connected().to_s
# Get the interface of function module created for the Blog
# Authenticate from PHP to a Web Service using X.509 Certificates
# Authenticate from PHP to a Web Service using X.509 Certificates
irep = rfc2.discover("Z_HELLO")
irep.NAME.value = "Gregor"
rfc2.call(irep)
puts "GREETING: " + irep.GREETING.value.to_s
# close connection 2
#
print "close connection 2: ",
rfc2.close(), "
"
# close connection 1
print "close connection 1: ",
rfc.close(),
"
/usr/local/src/saprfc-0.30# ruby test/ext-logon.rb
Connection id: 1
Are we connected: true USER_ID: G.WOLF
Connection id: 2
Are we connected: true GREETING: Hello Gregor , you are logged in as G.WOLF
close connection 2: 1
close connection 1: 1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |