스크립트에서 비즈니스 논리를 사용하여 액세스 권한 부여

비즈니스 규칙 스크립트를 사용하여 액세스를 확인하기 위한 런타임 논리를 제공합니다. 비즈니스 규칙에 대한 자세한 내용은 비즈니스 규칙을 참조하세요.

작업에 비즈니스 규칙을 할당하려면 먼저 작업을 나타내는 IAzTask 개체의 BizRuleLanguage 속성을 설정합니다. 스크립트는 VBScript(Visual Basic Scripting Edition) 프로그래밍 언어 또는 JScript 개발 소프트웨어를 사용하여 작성해야 합니다. 스크립트 언어를 지정한 후 스크립트의 문자열 표현을 사용하여 IAzTask 개체의 BizRule 속성을 설정합니다.

연결된 비즈니스 규칙이 있는 작업에 포함된 작업에 대한 액세스를 확인할 때 애플리케이션은 IAzClientContext 개체의 AccessCheck 메서드에 대한 varParameterNamesvarParameterValues 매개 변수로 전달될 동일한 크기의 두 배열을 만들어야 합니다. 클라이언트 컨텍스트를 만드는 방법에 대한 자세한 내용은 스크립트에서 클라이언트 컨텍스트 설정을 참조하세요.

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)
 
%>