#################################################################################################### # System Schema #################################################################################################### #################################################################################################### # System Rule #################################################################################################### #################################################################################################### # TRANSLATIONS DEFINITION #################################################################################################### data _system_translations { ConvertFrom-StringData @' CheckAdRmsProvisioned_Title=AD RMS is not fully installed and configured. CheckAdRmsProvisioned_Problem=AD RMS must be fully installed and configured to complete a scan for AD RMS best practices. CheckAdRmsProvisioned_Impact=The scan for AD RMS best practices could not be completed because AD RMS is not fully installed and configured. CheckAdRmsProvisioned_Resolution=AD RMS needs to be installed first. Use Server Manager to add the AD RMS role and configure role services. CheckAdRmsSSLConnection_Title=SSL Status CheckAdRmsSSLConnection_Problem=Warning: Did you know that you are not using HTTPS for your cluster URL cluster URL '{0}'? CheckAdRmsSSLConnection_Impact=The communication between client and AD RMS server is not secure. CheckAdRmsSSLConnection_Resolution=If this is a new setup, uninstall and re-deploy AD RMS using SSL security connection. CheckAdRmsSSLConnection_Compliant=The AD RMS Best Practices Analyzer scan has determined that you are in compliance with this best practice. CheckAdRmsSuperUserConfiguration_Title=AD RMS super user configuration CheckAdRmsSuperUserConfiguration_Problem=Alert: Please be aware that your AD RMS super user {0} is enabled. It is okay to have your super user enabled if you are using a 3rd party dependency. CheckAdRmsSuperUserConfiguration_Impact=AD RMS server super user can consume all protected content protected by this server. CheckAdRmsSuperUserConfiguration_Resolution=Disable AD RMS super user from AD RMS administration tool. CheckAdRmsSuperUserConfiguration_Compliant=The AD RMS Best Practices Analyzer scan has determined that you are in compliance with this best practice. '@ } Import-LocalizedData -BindingVariable _system_translations -fileName ADRMS.psd1 #################################################################################################### # # The followings are the synclet PowerShell Script for Scenario: AdRms # #################################################################################################### # #################################################################################################### ## Check URL is HTTPS or HTTP #################################################################################################### function IsHttpsUrl( [string] $url ) { $result = $false if ($url -ne $null) { $url = $url.ToLower().Trim() if ($url.IndexOf("https://") -eq 0) { $result = $true } } if ($result) { return 'true' } else { return 'false' } } #################################################################################################### ## Get Cluster Policy. The return values are ($IsSuccess, $PolicyValue) #################################################################################################### function GetClusterPolicy( [string] $policyName ) { $regVal = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\DRMS\ConnectionString" if ($regVal -eq $null) { return ($false, $null) } $conntionString = $regVal.ConfigDatabaseConnectionString if ($conntionString -eq $null) { return ($false, $null) } $conn = $null Try { $conn = new-Object System.Data.SqlClient.SqlConnection($conntionString) $conn.Open() $cmd = new-Object System.Data.SqlClient.SqlCommand("spa_GetPolicy", $conn) $cmd.CommandType = [System.Data.CommandType]'StoredProcedure' $cmd.Parameters.Add("@Name", $policyName) | out-Null $cmd.Parameters.Add("@ReturnCode", [System.Data.SqlDbType]'NVarChar', 255) | out-Null $cmd.Parameters.Add("@ReturnString", [System.Data.SqlDbType]'Int') | out-Null $cmd.Parameters["@ReturnCode"].Direction = [System.Data.ParameterDirection]'Output' $cmd.Parameters["@ReturnString"].Direction = [System.Data.ParameterDirection]'Output' $rdr = $cmd.ExecuteScalar() # make policy value as string always $policyVal = '' if ($rdr -ne $null) { $policyVal = $rdr.ToString() } return ($true, $policyVal) } Catch { return ($false, $null) } Finally { if ($conn -ne $null) { $conn.Close() } } } #################################################################################################### ## Create XML Document #################################################################################################### function Create-DocumentElement( $ns ) { [xml] "" } #################################################################################################### ## Add Elements to XML Doc #################################################################################################### function Append-ProvisionedRule-Element($doc, $ns, $isProvisioned) { $parent = $doc.CreateElement("ProvisioningInfo", $ns) $child = $doc.CreateElement("IsProvisioned", $ns) if($isProvisioned) { $child.set_InnerText( "true" ) } else { $child.set_InnerText( "false" ) } [void] $parent.AppendChild( $child ) [void] $doc.DocumentElement.AppendChild( $parent ) } #################################################################################################### ## Add Elements to XML Doc #################################################################################################### function Append-Rule1-Elements($doc, $ns) { $results = GetClusterPolicy("LicensingClusterUrl") if ($results -eq $null) { return } if ($results[0] -eq $false) { return } $policyValue = $results[1] $policyFlag = IsHttpsUrl( $policyValue ) $parent = $doc.CreateElement("HttpsUrlInfo", $ns) $child = $doc.CreateElement("IsHttps", $ns) $child.set_InnerText( $policyFlag ) [void] $parent.AppendChild( $child ) $child = $doc.CreateElement("IntranetLicensingUrl", $ns) $child.set_InnerText( $policyValue ) [void] $parent.AppendChild( $child ) [void] $doc.DocumentElement.AppendChild( $parent ) } #################################################################################################### ## Add Elements to XML Doc #################################################################################################### function Append-Rule2-Elements($doc, $ns) { $results = GetClusterPolicy("IsEnabledSuperUser") if ($results -eq $null) { return } if ($results[0] -eq $false) { return } if ($results[1] -eq $null) { return } if ($results[1] -eq '0') { $policyFlag = 'false' } else { $policyFlag = 'true' } $results = GetClusterPolicy("SuperUserGroupEmail") $policyValue = '' if ($results -ne $null) { if ($results[0] -eq $true) { if ($results[1] -ne $null) { $policyValue = $results[1].Trim() } } } # check email is not 'None' or empty. Otherwise, the super user is not enabled in licensing pipeline if ($results[1] -ieq '') { $policyFlag = 'false' } if ($results[1] -ieq 'none') { $policyFlag = 'false' } $parent = $doc.CreateElement("SuperUserEnablingInfo", $ns) $child = $doc.CreateElement("IsEnabledSuperUser", $ns) $child.set_InnerText( $policyFlag ) [void] $parent.AppendChild( $child ) $child = $doc.CreateElement("SuperUserGroupEmail", $ns) $child.set_InnerText( $policyValue ) [void] $parent.AppendChild( $child ) [void] $doc.DocumentElement.AppendChild( $parent ) } #################################################################################################### ## Check AD RMS is installed #################################################################################################### function IsRoleInstalledInServerManager( $roleId ) { $isSrvMgrLoaded = $false $moduleList = Get-Module foreach($module in $moduleList) { if ($module -ne $null) { if ($module.Name -ieq 'ServerManager') { $isSrvMgrLoaded = $true break } } } if ($isSrvMgrLoaded -eq $false) { Import-Module ServerManager } $roleInstalled = $false $roleList = Get-WindowsFeature $roleId foreach( $roleObj in $roleList) { if (($roleObj -ne $null) -and ($roleObj.Name -ieq $roleId)) { $roleInstalled = $roleObj.Installed break } } Remove-Module ServerManager return $roleInstalled } #################################################################################################### ## Check AD RMS is Provisioned #################################################################################################### function IsProvisioned( ) { $regPath = "HKLM:\SOFTWARE\Microsoft\DRMS" $regPathExist = Test-Path $regPath if($regPathExist -eq $false) { return $false } $regVal = Get-ItemProperty $regPath if($regVal.ConfigStatus -eq 3) { return $true } else { return $false } } #################################################################################################### # Main() synclet logic #################################################################################################### # targetNamespace $tns="http://schemas.microsoft.com/bestpractices/models/ServerManager/AdRms/AdRmsComposite/2008/04" # # create a new XmlDocument $d = Create-DocumentElement $tns # # get the flag of ADRMS was installed or not $isAdRmsRoleInstalled = IsRoleInstalledInServerManager( 'ADRMS' ) $isAdrmsProvisioned = IsProvisioned # # run BPA after ADRMS installation if ($isAdRmsRoleInstalled -eq $true) { if($isAdrmsProvisioned -eq $true) { # create XmlElement for each object, and append them to the DocumentElement of the new document. Append-Rule1-Elements $d $tns Append-Rule2-Elements $d $tns } else { Append-ProvisionedRule-Element $d $tns $isAdrmsProvisioned } } # you can run BPA before ADRMS installation also # # send the document to the output stream $d ####################################################################################################