在脚本中将用户添加到应用程序组
在授权管理器中,应用程序组是一组用户和用户组。 应用程序组可以包含其他应用程序组,因此可以嵌套用户组。 应用程序组由 IAzApplicationGroup 对象表示。
允许应用程序组的成员执行一项任务或一组任务
将该应用程序组分配给包含这些任务的角色。
角色由 IAzRole 对象表示。
以下示例演示如何创建应用程序组、将用户添加为应用程序组的成员,以及如何将应用程序组分配给现有角色。 该示例假定驱动器 C 根目录中有一个名为 MyStore.xml 的现有 XML 策略存储,此存储包含名为 Expense 的应用程序,并且此应用程序包含名为 Expense 管理员的角色。
' Create the AzAuthorizationStore object.
Dim AzManStore
Set AzManStore = CreateObject("AzRoles.AzAuthorizationStore")
' Initialize the authorization store.
AzManStore.Initialize 2, "msxml://C:\MyStore.xml"
' Create an application object in the store.
Dim expenseApp
Set expenseApp= AzManStore.OpenApplication("Expense")
' Create an application group object.
Dim appGroup
Set appGroup = expenseApp.CreateApplicationGroup("Approvers")
' Add a member to the group.
' Replace with valid domain and user name.
appGroup.AddMemberName("domain\\username")
' Save information to the store.
appGroup.Submit
' Open a role object.
Dim adminRole
Set adminRole = expenseApp.OpenRole("Expense Administrator")
' Add the group to the role.
adminRole.AddAppMember("Approvers")
' Save the information to the store.
adminRole.Submit