次の方法で共有


スクリプトでのビジネス ロジックを使用したアクセスの修飾

ビジネス ルール スクリプトを使用して、アクセスを確認するための実行時ロジックを提供します。 ビジネス ルールの詳細については、「 ビジネス ルール」を参照してください。

ビジネス ルールをタスクに割り当てるには、まず、タスクを表す IAzTask オブジェクトの BizRuleLanguage プロパティを設定します。 スクリプトは、Visual Basic Scripting Edition (VBScript) プログラミング言語または JScript 開発ソフトウェアを使用して記述する必要があります。 スクリプト言語を指定したら、スクリプトの文字列表現を使用して IAzTask オブジェクトの BizRule プロパティを設定します。

関連付けられたビジネス ルールを持つタスクに含まれる操作のアクセスを確認する場合、アプリケーションは、IAzClientContext オブジェクトの AccessCheck メソッドの varParameterNames パラメーターと varParameterValues パラメーターとして渡される同じサイズの 2 つの配列を作成する必要があります。 クライアント コンテキストの作成の詳細については、「 スクリプトでのクライアント コンテキストの確立」を参照してください。

AccessCheck メソッドは、ビジネス ルール スクリプトに渡される AzBizRuleContext オブジェクトを作成します。 次に、スクリプトは AzBizRuleContext オブジェクトの BusinessRuleResult プロパティを設定します。 値 True はアクセスが許可されていることを示し、False の値はアクセスが拒否されることを示します。

委任された IAzScope オブジェクトに含まれる IAzTask オブジェクトにビジネス ルール スクリプトを割り当てることはできません。

次の例は、ビジネス ルール スクリプトを使用して、クライアントの操作へのアクセスをチェックする方法を示しています。 この例では、ドライブ C のルート ディレクトリに MyStore.xml という名前の既存の XML ポリシー ストアがあり、このストアに Expense という名前のアプリケーション、Submit Expense という名前のタスク、UseFormControl という名前の操作が含まれていることを前提としています。

<%@ Language=VBScript %>
<%
'  Create the AzAuthorizationStore object.
Dim AzManStore
Set AzManStore = CreateObject("AzRoles.AzAuthorizationStore")

'  Initialize the authorization store.
AzManStore.Initialize 0, "msxml://C:\MyStore.xml"

'  Open the application object in the store.
Dim expenseApp
Set expenseApp = AzManStore.OpenApplication("Expense")

'  Create a client context.
Dim clientName
clientName = Request.ServerVariables("LOGON_USER")
Dim clientContext
Set clientContext = _
    expenseApp.InitializeClientContextFromName(clientName)

'  Create a business rule for the Submit Expense task.

'  Open the Submit Expense task.
Dim submitTask
Set submitTask = expenseApp.OpenTask("Submit Expense")

'  Set the business rule language to VBScript.
submitTask.BizRuleLanguage = "VBScript"

'  Create a string with the business rule code.
Dim newline
newline = chr(13)
Dim bizRuleString
bizRuleString = "Dim Amount" + newline _
         +"AzBizRuleContext.BusinessRuleResult = FALSE" + newline _
         +"Amount = AzBizRuleContext.GetParameter(""ExpAmount"")" _
   +newline _
   +"if Amount < 500 then AzBizRuleContext.BusinessRuleResult = TRUE"

'  Assign the business rule to the Submit Expense task.
submitTask.BizRule = bizRuleString
                
'  Save the task information to the store.
submitTask.Submit

'  Open the operation to check.
Dim formOperation
Set formOperation = expenseApp.OpenOperation("UseFormControl")

'  Get the ID of the operation.
Dim operationID
operationID = formOperation.OperationID

'  Set up arrays for operations and results.
Dim Operations(1)
Operations(0) = operationID
Dim Results

'  Set up business rule parameters.
Dim bizNames(1)
Dim bizValues(1)
bizNames(0) = "ExpAmount"
bizValues(0) = 100

'  Check access.
Results = clientContext.AccessCheck _
    ("UseFormControl", Empty, Operations, bizNames, bizValues)
 
%>