授權規則是以 VBScript 或 JScript 所撰寫的指令碼,可包含於角色定義或工作定義中。授權規則判定是否可使用角色或工作。

使用授權規則,您可依指令碼可測試的任何條件為基礎來進行基本授權決定。這些可能包括特殊權限及權限,以及時間、帳單花費限制、帳戶餘額或其他條件。

授權管理員的設計目的不是用來撰寫或除錯授權規則。您可以在文字編輯器 (如記事本)、如 Visual Studio .NET 之類的整合式開發環境,或是所選的其他應用程式中撰寫指令碼。授權規則通常是由專業程式開發人員所撰寫。

如需建立授權規則和使用 [授權管理員] 應用程式開發介面 (API) 的相關資訊,請參閱授權管理員模型 (可能為英文網頁) (https://go.microsoft.com/fwlink/?linkid=64027)。如需其他建議的連結,請參閱授權管理員的資源

控制商務規則和授權規則的使用

控制每個用戶端的使用

從 Windows Server 2008 開始,商務規則和授權規則的使用將由登錄設定所控制。規則預設是停用的。舊版 Windows 不支援這項功能。

一般而言,您將使用作業系統所執行的設定程式或指令碼啟用授權規則和商務規則 (如果您的環境中正在使用這些規則)。

重要

這項設定是針對每個用戶端上的每個授權管理員應用程式進行個別控制。

以下的範例指令碼可啟用或停用應用程式的商務規則和應用程式規則:

'

' Enabling or disabling BizRules for an application

' This script uses Authorization Manager Administrative interfaces to enable or disable

' BizRules for a specified Authorization Manager application in a specified Authorization Manager policy store

On Error Resume Next

Set objArgs = WScript.Arguments

If objArgs.count <> 3 then

wscript.echo "Usage: SetBizRule ""AzManStoreURL"" ""AzApplicaitonName"" True/False"

wscript.echo "Example: SetBizRule ""msxml://d:\inetpub\wwwroot\AzStore.xml"" ""MyApp"" True"

wscript.echo "Run with 'cscript' command in cmd.exe to avoid msg boxes"

Else

' VBScript source code

Dim AzStoreObj

Dim AzManStoreURL : AzManStoreURL = objArgs(0)

Dim AzManAppName : AzManAppName = objArgs(1)

Dim BizRulesEnabled : BizRulesEnabled = objArgs(2)

' create azman object

Set AzStoreObj = CreateObject("AzRoles.AzAuthorizationStore")

If Err.Number > 0 Then

WScript.Echo "Can not create AzRoles.AzAuthorizationStore. Check Authorization Manager installation"

WScript.Quit

End If

' initialize store for Administration

' assumes store exists - if store is being created (e.g. an installing applicaion)

' use the value 3 instead of 2 in the call to IAzAuthorizationStore::initialize

Err.Clear

AzStoreObj.Initialize 2, AzManStoreURL

If Err.Number <> 0 Then

WScript.Echo "AzRoles.AzAuthorizationStore failed to initialize. Check store URL"

WScript.Quit

End If

' open applicaion

set AzApp = AzStoreObj.OpenApplication(AzManAppName)

If Err.Number <> 0 Then

WScript.Echo "AzRoles.AzAuthorizationStore failed to open application: " + AzManAppName + ". Check application Name."

WScript.Quit

End If

' set BizRulesEnabled property

WSCript.Echo "App BizRule Before:" & AzApp.BizRulesEnabled

AzApp.BizRulesEnabled = BizRulesEnabled

WSCript.Echo "App BizRule After:" & AzApp.BizRulesEnabled

If Err.Number = 0 Then

WScript.Echo "BizRulesEnabled is updated successfully."

Else

WScript.Echo "BizRulesEnabled is NOT updated successfully."

End If

End if

控制整個授權存放的使用

藉由在授權存放區內容工作表頁的 [限制] 索引標籤中設定授權規則限制,您可以:

  • 停用存放區的授權規則和商務規則。

  • 設定等候逾時值,以限制允許指令碼執行的時間長度上限。

  • 允許指令碼執行,但不設定等候逾時。

如需相關資訊,請參閱了解授權管理員存放限制

VBScript 範例

下列為經常授與權限的 VBScript 授權規則:

AzBizRuleContext.BusinessRuleResult = True

如需 VBScript 的相關資訊,請參閱 VBScript (可能為英文網頁) (https://go.microsoft.com/fwlink/?linkid=65964)。

JScript 範例

下列為經常授與權限的 JScript 授權規則:

AzBizRuleContext.BusinessRuleResult = true;

如需 JScript 的相關資訊,請參閱 JScript (可能為英文網頁) (https://go.microsoft.com/fwlink/?linkid=65963)。


目錄