次の方法で共有


スクリプトでビジネス ロジックを使用してアクセスを修飾する

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

タスクにビジネス ルールを割り当てるには、まず、タスクを表す 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)
 
%>