如何通过 VBS 使用 SSO 登录 SAP? [英] How to Logon on SAP with SSO via VBS?

查看:130
本文介绍了如何通过 VBS 使用 SSO 登录 SAP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 VBScript 来打开 SAP 会话,并具有单点登录功能.

I'm trying to write a VBScript that opens a SAP session, with Single-Sign On capability.

我已经在此处和其他网站上找到了有关此主题或类似主题的一些信息,但没有一个适合我的要求..

I've already found some information about this topic, or similar ones, here and on other sites, but none of them suit my requirement..

这是我到目前为止的内容,摘自 SAP 论坛:

This is what I have so far, taken from a SAP Discussion Forum:

但是在 SAP GUI 中发生错误;

But an error happens in the SAP GUI;

Hostame 'PRD' 未知

Hostame 'PRD' unknown

行:896
方法:NiPGetHostByName:找不到PRD"

Line: 896
Method: NiPGetHostByName: 'PRD' not found

有人可以帮我吗?

Option Explicit
Dim WSHShell, SAPGUIPath, SID, InstanceNo, WinTitle
Set WSHShell = WScript.CreateObject("WScript.Shell")
If IsObject(WSHShell) Then
    SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
    SID = "PRD"
    InstanceNo = "00"
    WSHShell.Exec SAPGUIPath & "sapgui.exe " & SID & " " & _
      InstanceNo
    WinTitle = "SAP"
    While Not WSHShell.AppActivate(WinTitle)
      WScript.Sleep 250
    Wend
    Set WSHShell = Nothing
End If

推荐答案

完全公开,我不使用 SAP,所以我说的任何内容都纯属猜测.

看了一会儿问题,我可能有一个建议.

After looking at the question for a little while, I may have a suggestion.

该错误直接来自 SAP GUI,并且非常详细,这让我们可以做出一些假设;

The error is coming directly from the SAP GUI and is quite detailed, which allows us to make some assumptions;

  1. 错误来自 SAP GUI,因此 VBScript 执行没有问题.
  2. 问题可能与传递到 SAP GUI 的信息有关.

让我们尝试分解错误.有了这个特殊的错误,我们有幸获得了丰富的信息(将挑选出一些关键信息);

Let's try breaking down the error. With this particular error we are blessed with a wealth of information (will pick out some key ones);

  • 模块:我们被告知此错误源自哪个文件.
  • 行:发生错误的行.
  • 方法:发生错误的方法以及引发的错误.
  • 返回代码:我们可以使用它来查找特定的 SAP GUI 返回代码.但是,前提是文档足够详细以包含它.也可以通过互联网搜索来查找产品特定的错误代码.

有了所有这些信息,两件事变得显而易见;

Armed with all this information, two things become apparent;

  1. 该方法称为 NiPGetHostByName,这表明 SAP GUI 期望使用名称定位主机.
  2. 根据问题中的代码和 SAP 中连接列表的随附屏幕截图判断,PRD 值似乎是 SID 列而不是名称.
  1. The Method is called NiPGetHostByName which suggests the SAP GUI is expecting to locate the Host using the Name.
  2. Judging by the code in the question and the accompanying screenshot of the connections list in SAP the PRD value appears to be the SID column not the Name.

那么,您是否应该传递名称而不是 SID,因为它看起来 SAP GUI 不能从 SID 工作并且错误地假定 PRD 是名称,因此没有找到它?

So, should you possibly be passing the Name instead of the SID as it appears the SAP GUI is not working from the SID and wrongly assumes PRD is the Name and hence doesn't find it?

我建议尝试类似的东西;

I would suggest trying something like;

Option Explicit
Dim WSHShell, SAPGUIPath, SID, InstanceNo, WinTitle, Name
Set WSHShell = WScript.CreateObject("WScript.Shell")
If IsObject(WSHShell) Then
    SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
    Name = """1. SAP ECC Production (PRD)"""
    SID = "PRD"
    InstanceNo = "00"
    WSHShell.Exec SAPGUIPath & "sapgui.exe " & Name & " " & _
      InstanceNo
    WinTitle = "SAP"
    While Not WSHShell.AppActivate(WinTitle)
      WScript.Sleep 250
    Wend
    Set WSHShell = Nothing
End If

这篇关于如何通过 VBS 使用 SSO 登录 SAP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆