Security.CreateCategories 方法

创建一个或多个安全类别。

命名空间:  WebSvcSecurity
程序集:  ProjectServerServices(位于 ProjectServerServices.dll 中)

语法

声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CreateCategories", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Security/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Security/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub CreateCategories ( _
    categories As SecurityCategoriesDataSet _
)
用法
Dim instance As Security
Dim categories As SecurityCategoriesDataSet

instance.CreateCategories(categories)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CreateCategories", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Security/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Security/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CreateCategories(
    SecurityCategoriesDataSet categories
)

参数

备注

categories参数必须包含至少一个SecurityCategoriesDataSet.SecurityCategoriesRow定义新的类别。SecurityCategoriesDataTable可以包含多个SecurityCategoriesRow对象。Project Server 验证以下每个SecurityCategoriesRow :

  • 唯一的类别名称和 GUID

  • 是否存在用户和组 (如果有的话) 具有类别权限

  • 存在的类别中的项目 (如果有)

  • 存在的类别中的资源 (如果有)

SecurityCatagoriesDataSet中有七个DataTable对象。仅SecurityCategoriesDataTable必须包含数据。模拟运算表是按顺序,如下所示:

  1. SecurityCategories  每个行指定类别的 GUID、 名称和说明。创建安全类别需要的 GUID 和 (WSEC_CAT_UID 和 WSEC_CAT_NAME) 的名称。

  2. UserRelations  可选。每个行指定类别 GUID 和资源的 GUID。

  3. GroupRelations  可选。指定 GUID 的类别和组 GUID。

  4. 用户权限  可选。每个行指定类别的 GUID、 资源的 GUID 和权限,并设置Allow或Deny的权限。

  5. GroupPermissions  可选。每个行指定类别的 GUID、 组 GUID 和权限,并设置Allow或Deny的权限。

  6. SecurityCategoryObjects  可选。每个行指定类别的 GUID、 对象类型 (项目或资源) 和对象的 GUID。

  7. SecurityCategoryRules  可选。每个行指定类别的 GUID、 对象类型 (项目或资源) 和规则类型。有关规则枚举的信息,请参阅ProjectSecurityRulesResourceSecurityRules

有效的类别的示例,请单击Project Web App,在管理类别页上的类别以在添加或编辑类别页上查看的字段和设置。

Project Server 权限

权限

说明

ManageSecurity

允许用户管理 Project Server 安全性。全局权限。

示例

以下示例调用CreateCategories创建两个SecurityCategoriesDataSetmultiCategoryDs中指定的安全类别。

有关其他信息和使用一组创建一个安全类别的完整示例应用程序,请参阅使用 PSI 中的安全措施。您可以将以下代码添加到示例应用程序和修改resourceGuid的值。运行应用程序之后,请在Project Web App中, 打开管理类别页上,然后单击测试类别 1测试类别 2来查看结果。

/* 
 * Add this code to the sample code in the article
 * Using Security Methods in the PSI.
 */

// Set the GUID for an existing resource.
Guid resourceUid = new Guid("a1fcbf91-e91d-44e2-a4a7-3b4b698cb984");

Guid category1Guid = Guid.NewGuid();
Guid category2Guid = Guid.NewGuid();

SvcSecurity.SecurityCategoriesDataSet multiCategoryDs =
   new SvcSecurity.SecurityCategoriesDataSet();
SvcSecurity.SecurityCategoriesDataSet.SecurityCategoriesRow category1Row =
   multiCategoryDs.SecurityCategories.NewSecurityCategoriesRow();
SvcSecurity.SecurityCategoriesDataSet.SecurityCategoriesRow category2Row =
   multiCategoryDs.SecurityCategories.NewSecurityCategoriesRow();

category1Row.WSEC_CAT_UID = category1Guid;
category1Row.WSEC_CAT_NAME = "Test Category 1";
category1Row.WSEC_CAT_DESC = "This is test category 1.";
multiCategoryDs.SecurityCategories.AddSecurityCategoriesRow(category1Row);

category2Row.WSEC_CAT_UID = category2Guid;
category2Row.WSEC_CAT_NAME = "Test Category 2";
category2Row.WSEC_CAT_DESC = "This is test category 2.";
multiCategoryDs.SecurityCategories.AddSecurityCategoriesRow(category2Row);

// (Optional) Add a user to category 1.
SvcSecurity.SecurityCategoriesDataSet.UserRelationsRow userRelationsRow =
   multiCategoryDs.UserRelations.NewUserRelationsRow();
userRelationsRow.WSEC_CAT_UID = category1Guid;
// Change the following GUID to a resource that is on your system.
Guid existingResUid = new Guid("88979803-2230-48b4-b23b-4af0e4a40392");
userRelationsRow.RES_UID = existingResUid;
multiCategoryDs.UserRelations.AddUserRelationsRow(userRelationsRow);

// (Optional) Specify the permissions for the user on category 1.
SvcSecurity.SecurityCategoriesDataSet.UserPermissionsRow userPermRow =
   multiCategoryDs.UserPermissions.NewUserPermissionsRow();
userPermRow.WSEC_CAT_UID = category1Guid;
userPermRow.RES_UID = existingResUid;
userPermRow.WSEC_ALLOW = true;

// For example, add the "Open Project" permission.
userPermRow.WSEC_FEA_ACT_UID = PSLibrary.PSSecurityCategoryPermission.OpenProject;
multiCategoryDs.UserPermissions.AddUserPermissionsRow(userPermRow);

// (Optional) Add an object (project or resource) to category 2.
SvcSecurity.SecurityCategoriesDataSet.SecurityCategoryObjectsRow category2ObjectRow =
   multiCategoryDs.SecurityCategoryObjects.NewSecurityCategoryObjectsRow();
category2ObjectRow.WSEC_CAT_UID = category2Guid;
category2ObjectRow.WSEC_OBJ_TYPE_UID = PSLibrary.PSSecurityObjectType.Project;

// Add an existing project to category 2. 
// Change the following GUID to a project that is on your system.
category2ObjectRow.WSEC_OBJ_UID = new Guid("BC323C21-B7E4-4631-AF99-C44E5C52BA4E");
multiCategoryDs.SecurityCategoryObjects.AddSecurityCategoryObjectsRow(category2ObjectRow);

// (Optional) Set some dynamic rules on category 2.
SvcSecurity.SecurityCategoriesDataSet.SecurityCategoryRulesRow category2RulesRow1 =
   multiCategoryDs.SecurityCategoryRules.NewSecurityCategoryRulesRow();
category2RulesRow1.WSEC_CAT_UID = category2Guid;
category2RulesRow1.WSEC_OBJ_TYPE_UID = PSLibrary.PSSecurityObjectType.Project;
category2RulesRow1.WSEC_OBJ_RULE_TYPE = (int)PSLibrary.ProjectSecurityRules.OwnerAtSameRbsNode;
multiCategoryDs.SecurityCategoryRules.AddSecurityCategoryRulesRow(category2RulesRow1);

SvcSecurity.SecurityCategoriesDataSet.SecurityCategoryRulesRow category2RulesRow2 =
   multiCategoryDs.SecurityCategoryRules.NewSecurityCategoryRulesRow();
category2RulesRow2.WSEC_CAT_UID = category2Guid;
category2RulesRow2.WSEC_OBJ_TYPE_UID = PSLibrary.PSSecurityObjectType.Project;
category2RulesRow2.WSEC_OBJ_RULE_TYPE = (int)PSLibrary.ProjectSecurityRules.AllCurrentAndFuture;
multiCategoryDs.SecurityCategoryRules.AddSecurityCategoryRulesRow(category2RulesRow2);

SvcSecurity.SecurityCategoriesDataSet.SecurityCategoryRulesRow category2RulesRow3 =
   multiCategoryDs.SecurityCategoryRules.NewSecurityCategoryRulesRow();
category2RulesRow3.WSEC_CAT_UID = category2Guid;
category2RulesRow3.WSEC_OBJ_TYPE_UID = PSLibrary.PSSecurityObjectType.Project;
category2RulesRow3.WSEC_OBJ_RULE_TYPE = (int)PSLibrary.ProjectSecurityRules.ManagedByUser;
multiCategoryDs.SecurityCategoryRules.AddSecurityCategoryRulesRow(category2RulesRow3);

security.CreateCategories(multiCategoryDs);

另请参阅

引用

Security 类

Security 成员

WebSvcSecurity 命名空间

其他资源

使用 PSI 中的安全方法