共用方式為


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 中的安全性方法