Security.CreateCategories method

Office 2013 and later

Creates one or more security categories.

Namespace:  WebSvcSecurity
Assembly:  ProjectServerServices (in ProjectServerServices.dll)

[SoapDocumentMethodAttribute("", RequestNamespace = "", 
	ResponseNamespace = "", 
	Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CreateCategories(
	SecurityCategoriesDataSet categories


Type: WebSvcSecurity.SecurityCategoriesDataSet

Contains the information about one or more security categories.

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




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

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

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

category1Row.WSEC_CAT_UID = category1Guid;
category1Row.WSEC_CAT_NAME = "Test Category 1";
category1Row.WSEC_CAT_DESC = "This is test category 1.";

category2Row.WSEC_CAT_UID = category2Guid;
category2Row.WSEC_CAT_NAME = "Test Category 2";
category2Row.WSEC_CAT_DESC = "This is test category 2.";

// (Optional) Add a user to category 1.
SvcSecurity.SecurityCategoriesDataSet.UserRelationsRow userRelationsRow =
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;

// (Optional) Specify the permissions for the user on category 1.
SvcSecurity.SecurityCategoriesDataSet.UserPermissionsRow userPermRow =
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;

// (Optional) Add an object (project or resource) to category 2.
SvcSecurity.SecurityCategoriesDataSet.SecurityCategoryObjectsRow category2ObjectRow =
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");

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

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

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