다음을 통해 공유


Security.CreateCategories Method

Creates one or more security categories.

Namespace:  [Security Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/Security.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/Security.asmx?wsdl

Syntax

'Declaration
<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 _
)
'Usage
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
)

Parameters

Remarks

The categories parameter must contain at least one SecurityCategoriesDataSet.SecurityCategoriesRow that defines a new category. The SecurityCategoriesDataTable can contain multiple SecurityCategoriesRow objects. Project Server validates each SecurityCategoriesRow for the following:

  • Unique category name and GUID

  • Existence of users and groups (if any) that have the category permission

  • Existence of projects (if any) in the category

  • Existence of resources (if any) in the category

There are seven DataTable objects in a SecurityCatagoriesDataSet. Only the SecurityCategoriesDataTable must contain data. The data tables are in order, as follows:

  1. SecurityCategories   Each row specifies the category GUID, name, and description. Only the GUID and name (WSEC_CAT_UID and WSEC_CAT_NAME) are required to create a security category.

  2. UserRelations   Optional. Each row specifies the category GUID and the resource GUID.

  3. GroupRelations   Optional. Specifies the category GUID and the group GUID.

  4. UserPermissions   Optional. Each row specifies the category GUID, resource GUID, and permission, and sets Allow or Deny for the permission.

  5. GroupPermissions   Optional. Each row specifies the category GUID, group GUID, and permission, and sets Allow or Deny for the permission.

  6. SecurityCategoryObjects   Optional. Each row specifies the category GUID, object type (project or resource), and object GUID.

  7. SecurityCategoryRules   Optional. Each row specifies the category GUID, object type (project or resource), and rule type. For information about the rule enumerations, see ProjectSecurityRules and ResourceSecurityRules.

For examples of valid categories, click a category on the Manage Categories page in Project Web App, to see the fields and settings on the Add or Edit Category page.

Project Server Permissions

Permission

Description

ManageSecurity

Allows a user to manage Project Server security. Global permission.

Examples

The following example calls CreateCategories to create two security categories that are specified in the SecurityCategoriesDataSetmultiCategoryDs.

For additional information and a complete sample application that creates one security category with a group, see Using Security Methods in the PSI. You can add the following code to the sample application and modify the value of resourceGuid. After you run the application, open the Manage Categories page in Project Web App, and then click Test Category 1 and Test Category 2 to see the results.

/* 
 * 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();

SecurityWebSvc.SecurityCategoriesDataSet multiCategoryDs =
   new SecurityWebSvc.SecurityCategoriesDataSet();
SecurityWebSvc.SecurityCategoriesDataSet.SecurityCategoriesRow category1Row =
   multiCategoryDs.SecurityCategories.NewSecurityCategoriesRow();
SecurityWebSvc.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.
SecurityWebSvc.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.
SecurityWebSvc.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.
SecurityWebSvc.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.
SecurityWebSvc.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);

SecurityWebSvc.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);

SecurityWebSvc.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);

See Also

Reference

Security Class

Security Members

Security Web Service

Other Resources

Using Security Methods in the PSI