自定义 SAM 自动登录应用程序脚本

内容
cminder12901cn
内容
可通过自定义 SAM 自动登录应用程序脚本来增强 SAM 自动登录功能。 使用 SAM 自动登录 SDK 创建自定义脚本,使用户能够自动登录到端点。
以下过程说明自定义自动登录应用程序脚本的方式:
  1. 创建 Visual BASIC 脚本
    您可以使用标准 COM 对象或 ACLauncher ActiveX 方式创建脚本。
  2. Privileged Identity Manager
    企业控制台中配置登录应用程序,然后将创建的脚本与应用程序相关联。
  3. 将登录脚本与端点关联
SAM 自动登录应用程序 Visual Basic 脚本
SAM 自动登录应用程序使用 Visual Basic 脚本来启用用户的自动登录。 您可以自定义 Visual Basic 脚本,以便创建新登录应用程序或修改现有登录应用程序。
SAM 自动登录应用程序脚本包含从企业管理服务器下载到客户端计算机时 ActiveX 以值替换的变量。 企业管理服务器处理脚本,并以值替换关键字。 然后,ActiveX 执行客户端计算机上的脚本。
SAM 自动登录应用程序脚本位于以下目录:
JBOSS_HOME/server/default/deploy/IdentityMinder.ear/config/sso_scripts
元素
SAM 登录应用程序脚本包含以下键:
  • #host#
    指定用户自动登录到的端点名称。
  • #username#
    指定签出特权帐户。
  • #password#
    指定要签出的特权帐户密码。
  • #userdomain#
    (Active Directory) 指定特权帐户域名。
  • #isActiveServletUrl#
    指定 ACLauncher ActiveX 用于检查帐户密码签入事件的 URL。
  • #CheckinUrl#
    在用户注销端点的情况下,指定 ACLauncher ActiveX 用于签入帐户密码的 URL。
  • #Owner#
    指定帐户所有者名称。
    注意:
    如果未针对帐户设置属性,那么键指定该帐户所属的端点属性。
  • #Department#
    指定部门名称。
    注意:
    如果未针对帐户设置属性,那么键指定该帐户所属的端点属性。
  • #SessionidUrl#
    如果会话记录在 ObserverIT Enterprise,指定 ACLauncher ActiveX 用于发送已记录会话 ID 的 URL。
  • #CustomInfo1...5#
    指定特定帐户的属性。 您可以指定多达五个自定义特定帐户的属性。
    注意
    :如果没有针对帐户设置自定义属性,那么键指定该帐户所属的端点属性。
以下是 SAM 自动登录应用程序脚本的片段:
Set pupmObj = CreateObject("ACLauncher.ACWebLauncher") hwnd = pupmObj.LauncheRDP("#host#", "#userDomain#\#userName#", "#password#") ' Set window close event pupmObj.SetWindowCloseEvent(hwnd) ' Set server checkin event pupmObj.SetServerCheckinEvent("#isActiveServletUrl#") ' Wait until one of the events signaled rc = pupmObj.WaitForEvents() If rc = 1 Then 'user has closed the window - notify the server side pupmObj.SendCheckinEvent("#CheckinUrl#") ElseIf rc = 2 Then 'timeout elapsed - close the window call pupmObj.CloseWindow(hwnd, 0) ElseIf rc = 3 Then 'the account was checkedin at the server side - close the window call pupmObj.CloseWindow(hwnd, 120) End If
结构
SAM 自动登录应用程序脚本结构如下所示:
  • COM 对象的初始化
    Set pupmObj = CreateObject("ACLauncher.ACWebLauncher")
  • 自动登录应用程序的执行
    hwnd = pupmObj.LauncheRDP("#host#", "#userDomain#\#userName#", "#password#")
  • 后继执行任务 - 密码签入、交互式登录或超时
    ' Wait until one of the events signaled rc = pupmObj.WaitForEvents() If rc = 1 Then 'user has closed the window - notify the server side pupmObj.SendCheckinEvent("#CheckinUrl#") ElseIf rc = 2 Then 'timeout elapsed - close the window call pupmObj.CloseWindow(hwnd, 0) ElseIf rc = 3 Then 'the account was checkedin at the server side - close the window call pupmObj.CloseWindow(hwnd, 120) End If
要记录登录应用程序会话,请将记录说明添加到脚本中,如下所示:
  • 在初始化部分, 添加以下内容:
    Set observeIT = CreateObject("ObserverIT.AgentAPI.Proxy")
  • 在应用程序执行部分,添加以下内容:
    'Get application processid processID = pupmObj.GetWindowProcessID(hwnd) 'Start recording sessionid = observeIT.StartByProcessID(processID, true) 'Send the sessions if to the ENTM server pupmObj.AssignSessionID "#SessionidUrl#" ,sessionId
  • 在后执行部分,添加以下内容:
    'Stop recording observeIT.StopBySessionId sessionId, true
方法
ACLauncher ActiveX 使用以下方法:
LauncheRDP (BSTR bsHostName, BSTR bsUserName, BSTR bsPassword, VARIANT *phWindow);
启动带有输入凭据的远程桌面会话并返回远程桌面窗口句柄
示例
:Dim test Set test = CreateObject("ACLauncher.ACWebLauncher") Hwnd = test.LauncheRDP("hostname.com", "hostname\administrator", "password")
LaunchePUTTY (BSTR bsHostName, BSTR bsUserName, BSTR bsPassword, VARIANT *phWindow);
启动带有输入凭据的 PuTTY 会话并返回 PuTTY 窗口句柄
示例
:Dim test Set test = CreateObject("ACLauncher.ACWebLauncher") Hwnd = test。 LaunchePUTTY ("hostname.ca.com", "root", "password")
LauncheProcessAsUser (BSTR bsApplication, BSTR bsCommandline, BSTR bsUsername, BSTR bsPassword, VARIANT *phWindow);
启动带有输入凭据的过程并返回过程窗口句柄
示例
:Dim test Set test = CreateObject("ACLauncher.ACWebLauncher") Hwnd = test.LauncheProcessAsUser("cmd.exe", "/k echo This console is run under %USERNAME% account...", "administrator" , "password")
GetWindowProcessID(VARIANT *phWindow, LONG *pProcessID);
返回指定窗口句柄的过程 ID
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") id = test.GetWindowProcessID(hwnd) test.Echo "Process ID = " & id
GetWindowTitle(VARIANT *phWindow, BSTR *pbsTitle);
返回指定窗口句柄的标题 ID
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") title = test.GetWindowTitle(hwnd)
CloseWindow(VARIANT *phWindow, LONG Seconds);
显示对话框,消息指定窗口将在 X 秒内关闭,并关闭指定窗口句柄的窗口
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") test.Sleep(5000) test.CloseWindow(hwnd, 60)
SetTimeoutEvent(LONG seconds);
为“WaitForEvents”方法指定超时。 一旦到达超时值,WaitForEvents 方法则从其阻止调用返回一个返回值,表示到达超时
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") test.SetTimeoutEvent(10)
SetWindowCloseEvent(VARIANT *phWindow);
指定“WaitForEvents”方法的窗口关闭事件。 关闭窗口之后,“WaitForEvents”方法从其阻止调用返回并显示返回值,这些返回值表示窗口已关闭
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") test.SetWindowCloseEvent(hwnd)
SetServerCheckinEvent(BSTR bsURL);
将 SAM 签入事件设置为阻止执行条件。 ActiveX 每 5 秒查询一次 SAM
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") test.SetServerCheckinEvent("http://server.com/__azy?djfhwek5jy34brfhwkeb") (replace with variable)
WaitForEvents(VARIANT *pRetVal);
阻止脚本执行,直到注册条件之一正确。
选项
:1-用户已关闭窗口,2-已用超时时间,3-在服务器端密码签入
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") test.SetServerCheckinEvent("http://server.com/__azy?djfhwek5jy34brfhwkeb")
test.SetWindowCloseEvent(hwnd) test.SetTimeoutEvent(360) rc = test.WaitForEvents() If rc = 3 Then call test.CloseWindow(hwnd, 10) End If
SwitchToThisWindow(VARIANT *phWindow);
定位 Z 顺序顶端的窗口
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password") test.SwitchToThisWindow(hwnd)
SendCheckinEvent(BSTR bsURL);
用户关闭窗口时,发送签入事件
示例
:Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.LauncheRDP("hostname", "administrator", "password")
Sleep(LONG milliseconds);
暂停脚本执行
Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.Sleep(2000)
Echo(VARIANT* pArgs);
打印消息到屏幕
Set test = CreateObject("ACLauncher.ACWebLauncher") hwnd = test.Echo("Password Checkin")