Session Recording

未录制会话

如果未成功录制应用程序会话,请检查 Session Recording Agent 和 Session Recording Server 上的事件查看器中的应用程序事件日志。这样做可以提供有价值的诊断信息。

如果未录制会话,可能的原因可能如下所示:

  • 组件连接和证书。如果 Session Recording 组件相互之间无法进行通信,会话录制可能会失败。要解决录制问题,请验证是否已将所有组件正确配置为指向正确的计算机,以及所有证书是否均有效且已正确安装。
  • 非 Active Directory 域环境。Session Recording 设计为在 Microsoft Active Directory 域环境中运行。如果您不在 Active Directory 环境中运行,可能会遇到录制问题。确保所有 Session Recording 组件都在属于 Active Directory 域成员的计算机上运行。
  • 会话共享与活动策略冲突。Session Recording 将活动策略与用户打开的第一个已发布应用程序相匹配。随后在同一会话中打开的应用程序都将继续遵循对第一个应用程序有效的策略。要防止会话共享与活动策略冲突,请在单独的多会话操作系统 VDA 上发布冲突的应用程序。
  • 未启用录制。默认情况下,在多会话操作系统 VDA 上安装 Session Recording Agent 可启用 VDA 的录制功能。将活动录制策略配置为允许录制之后,才开始录制。
  • 活动录制策略不允许录制。仅当在会话满足活动录制策略规则时,才会录制会话。
  • Session Recording 服务未运行。对于要录制的会话,Session Recording Agent 服务必须在多会话操作系统 VDA 上运行,并且 Session Recording Storage Manager 服务必须在托管 Session Recording Server 的计算机上运行。
  • 未配置 MSMQ。如果未在运行 Session Recording Agent 的服务器上以及托管 Session Recording Server 的计算机上正确配置 MSMQ,可能会出现录制问题。
  • Session Recording 数据库组件未正确升级。升级现有安装时,必须严格遵循升级顺序。如果您的部署中有多个 Session Recording Server,则必须先升级安装了 Session Recording 数据库组件的 Session Recording Server。否则,会话录制将失败。要更正 Session Recording 数据库组件未正确升级的问题,请执行以下任一操作:

    • 找到安装了 Session Recording 数据库组件的 Session Recording Server。然后在其上运行 Citrix Virtual Apps and Desktops ISO 或 SessionRecordingAdministrationx64.msi 软件包。

    • 在部署中的任何 Session Recording Server 上运行以下脚本。运行脚本时,请提供 SessionRecordingAdministrationx64.msi 软件包的路径作为参数。

       param(
           [Parameter(Mandatory=$true)]
           [ValidateNotNullOrEmpty()]
           [string]$Installer
       )
       Add-Type -AssemblyName System.Data
      
       if (!(Test-Path "$PSScriptRoot\bin\lessmsi.exe")) {
           Write-Error "Download zip of binaries from https://github.com/activescott/lessmsi/releases/download/v1.10.0/lessmsi-v1.10.0.zip and extract to \bin in this folder!"
           exit
       }
      
       # 打开 MSI 数据库
       $msi = New-Object -ComObject WindowsInstaller.Installer
       $msidb = $msi.OpenDatabase($Installer, 0)
      
       # 查询文件表
       $query = "SELECT Version FROM File WHERE FileName = 'SMAUDD~1.DLL\|SsRecDatabase.dll'"
      
       $view = $msidb.OpenView($query)
       $view.Execute()
      
       # 获取 DLL 版本
       $record = $view.Fetch()
      
       $version = $record.GetType().InvokeMember("StringData", "GetProperty", $null, $record, 1)
       $parts = $version.Split(".")
       [int] $major = $parts[0]
       [int] $minor = $parts[1]
       $majorMinor = $parts[0..1] -join "."
       $versionCompare = $major * 100 + $minor
      
       # 获取数据库实例和名称
       $registryKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Citrix\SmartAuditor\Server")
       $dbName = $registryKey.GetValue("DatabaseName")
       $dbInstance = $registryKey.GetValue("SmAudDatabaseInstance")
      
      
       write-host "Upgrade db($dbInstance\$dbName) to version $version"
      
       $schemaVersionMap = @{}
       $schemaVersionMap["19.12"] = "1.2.3.0"
       $schemaVersionMap["22.3"] = "1.3.3.0"
       $schemaVersionMap["22.6"] = "1.3.4.0"
       $schemaVersionMap["22.9"] = "1.3.4.0"
       $schemaVersionMap["22.12"] = "1.3.5.0"
       $schemaVersionMap["23.3"] = "1.3.6.0"
       $schemaVersionMap["23.5"] = "1.3.7.0"
       $schemaVersionMap["23.8"] = "1.3.8.0"
      
       $DBSchemaUpdatePatchList = @(
           "1.1.0.0",
           "1.2.0.0",
           "1.2.1.0",
           "1.2.2.0",
           "1.2.3.0",
           "1.2.4.0",
           "1.2.5.0",
           "1.2.6.0",
           "1.2.7.0",
           "1.2.8.0",
           "1.2.9.0",
           "1.3.0.0",
           "1.3.1.0",
           "1.3.2.0",
           "1.3.3.0",
           "1.3.4.0",
           "1.3.5.0",
           "1.3.6.0",
           "1.3.7.0",
           "1.3.8.0"
       )
      
       $currentSchemaVersion = $schemaVersionMap[$majorMinor]
      
       # Connect db
       $conn = New-Object System.Data.SqlClient.SqlConnection
       $conn.ConnectionString = "workstation id=.;packet size=4096;integrated security=SSPI;data source=$dbInstance;persist security info=True;initial catalog=$dbName"
      
       # Open connection
       $conn.Open()
      
       # Get existing db schema version
       $cmdGetSchema = $conn.CreateCommand()
       $cmdGetSchema.CommandType = [System.Data.CommandType]::StoredProcedure
       $cmdGetSchema.CommandText = "[GetSchemaVersion]"
       $out1 = $cmdGetSchema.Parameters.Add("@Major", [System.Data.SqlDbType]::Int)
       $out1.Direction = [System.Data.ParameterDirection]::Output
       $out2 = $cmdGetSchema.Parameters.Add("@Minor", [System.Data.SqlDbType]::Int)
       $out2.Direction = [System.Data.ParameterDirection]::Output
       $out3 = $cmdGetSchema.Parameters.Add("@Build", [System.Data.SqlDbType]::Int)
       $out3.Direction = [System.Data.ParameterDirection]::Output
       $out4 = $cmdGetSchema.Parameters.Add("@Revision", [System.Data.SqlDbType]::Int)
       $out4.Direction = [System.Data.ParameterDirection]::Output
       $cmdGetSchema.ExecuteNonQuery()
      
       $existDbSchemaVersion = [string]::Format("{0}.{1}.{2}.{3}", $out1.Value, $out2.Value, $out3.Value, $out4.Value)
       write-host "Existing DB Schema Version: $existDbSchemaVersion"
      
       if ([string]::Compare($existDbSchemaVersion, $currentSchemaVersion) -lt 0) {
           Write-Output "Upgrade $existDbSchemaVersion to $currentSchemaVersion"
      
           & $PSScriptRoot\bin\lessmsi.exe x $Installer $PSScriptRoot\ SsRecDatabase.dll
           $tempdir = "$PSScriptRoot\SOURCEDIR\Program Files\Citrix\SessionRecording\Database\Bin"
           # Load assembly and get resource
           $asm = [Reflection.Assembly]::LoadFile("$tempdir\SsRecDatabase.dll")
      
           foreach ($patch in $DBSchemaUpdatePatchList) {
               if ([string]::Compare($existDbSchemaVersion, $patch) -le 0 -and [string]::Compare($patch, $currentSchemaVersion) -lt 0) {
                   write-host "Applying $patch"
                   # switch to db
                   $switchCmd = $conn.CreateCommand()
                   $switchCmd.CommandText = "use [$dbName]"
                   $switchCmd.ExecuteNonQuery()
      
                   $resStream = $asm.GetManifestResourceStream("SmAudDatabase.$patch-MigrateDatabase.sql")
                   $bytes = New-Object byte[] $resStream.Length
                   $resStream.Read($bytes, 0, $resStream.Length)
                   $script = [System.Text.Encoding]::UTF8.GetString($bytes)
      
                   $statements = [regex]::Split($script, "\s[gG][oO]\s")
                   foreach($statement in $statements) {
                       $upgradeCmd = $conn.CreateCommand()
                       $upgradeCmd.CommandText = $statement
                       $upgradeCmd.ExecuteNonQuery()
                   }
      
                   $existDbSchemaVersion = $patch
               } else {
                   write-host "Skip $patch"
               }
           }
           # UpdateStaticData
           $staticCmd = $conn.CreateCommand()
           $staticCmd.CommandText = "use [$dbName];if not exists(select * from [dbo].[StartReason] where ID=4) begin insert [dbo].[StartReason] values(4, 'Event Triggered') end"
           $staticCmd.ExecuteNonQuery()
      
           if ($versionCompare -ge 2308) {
               # upgrade record policy version
               $staticCmd = $conn.CreateCommand()
               $staticCmd.CommandText = "update [dbo].[PolicyDocument] set PolicyFileFormatMajorVersion = 1, PolicyFileFormatMinorVersion = 3 where SystemDefined = 1"
               $staticCmd.ExecuteNonQuery()
      
               # upgrade endreason
               $staticCmd = $conn.CreateCommand()
               $staticCmd.CommandText = "if not exists(select * from [dbo].[EndReason] where ID=5) begin insert [dbo].[EndReason] values(5 , 'Dormant') end"
               $staticCmd.ExecuteNonQuery()
           }
      
           if ($versionCompare -ge 2311) {
      
               # upgrade endreason
               $staticCmd = $conn.CreateCommand()
               $staticCmd.CommandText = "if not exists(select * from [dbo].[EndReason] where ID=6) begin insert [dbo].[EndReason] values(6 , 'Deny') end"
               $staticCmd.ExecuteNonQuery()
           }
           write-host "Upgrade success!"
       }
       else {
           Write-Output "Current schema version don't need upgrade"
       }
      
       $conn.Close()
       <!--NeedCopy-->
      
未录制会话