共用方式為


Security.CreateTemplates Method

Creates one or more security templates.

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/CreateTemplates", 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 CreateTemplates ( _
    templates As SecurityTemplatesDataSet _
)
'Usage
Dim instance As Security
Dim templates As SecurityTemplatesDataSet

instance.CreateTemplates(templates)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CreateTemplates", 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 CreateTemplates(
    SecurityTemplatesDataSet templates
)

Parameters

Remarks

The templates parameter must contain at least one SecurityTemplatesDataSet.SecurityTemplatesRow in the SecurityTemplates table that defines a new template. The SecurityTemplatesDataTable can contain multiple SecurityTemplatesRow objects. Project Server validates each SecurityTemplatesRow for the following:

  • Unique template name and GUID

There are three DataTable objects in a SecurityTemplatesDataSet. Only the SecurityTemplatesDataTable must contain data. The data tables are in order, as follows:

  1. SecurityTemplates   Each row specifies the category GUID, name, and description. Only the GUID and name (WSEC_TMPL_UID and WSEC_TMPL_NAME) are required to create a security category.

  2. CategoryPermissions   Optional. Each row specifies the template GUID and category permission GUID, and sets Allow or Deny for the permission. For information about the category permissions, see the PSSecurityCategoryPermission structure.

  3. GlobalPermissions   Optional. Each row specifies the template GUID and the global permission GUID, and sets Allow or Deny for the permission. For information about the global permissions, see the PSSecurityGlobalPermission structure.

For examples of valid templates, click a template on the Manage Templates page in Project Web App, to see the fields and settings on the Add or Edit Template page.

Project Server Permissions

Permission

Description

ManageSecurity

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

Examples

The following example creates a security template and adds a global permission that is set to Allow for the group.

For additional information and a basic sample application for testing the Security class methods, see Using Security Methods in the PSI. You can add the following code to the test application.

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

// Create a GUID for the new template.
Guid templateGuid = Guid.NewGuid();

// Specify basic template information.
SecurityWebSvc.SecurityTemplatesDataSet templateDs =
   new SecurityWebSvc.SecurityTemplatesDataSet();
SecurityWebSvc.SecurityTemplatesDataSet.SecurityTemplatesRow templateRow =
   templateDs.SecurityTemplates.NewSecurityTemplatesRow();
templateRow.WSEC_TMPL_NAME = "SDK Test Template";
templateRow.WSEC_TMPL_UID = templateGuid;
templateRow.WSEC_TMPL_DESC = "This is the SDK Test Template.";
templateDs.SecurityTemplates.AddSecurityTemplatesRow(templateRow);

// Specify a global permission for the template.
SecurityWebSvc.SecurityTemplatesDataSet.GlobalPermissionsRow globalPermissionRow =
   templateDs.GlobalPermissions.NewGlobalPermissionsRow();
globalPermissionRow.WSEC_TMPL_UID = templateGuid;
// Add a permission that applies to the group. 
// For example, add the "About Microsoft Office Project Server" permission.
globalPermissionRow.WSEC_FEA_ACT_UID =
   PSLibrary.PSSecurityGlobalPermission.AboutMicrosoftOfficeProjectServer;
globalPermissionRow.WSEC_ALLOW = true;
templateDs.GlobalPermissions.AddGlobalPermissionsRow(globalPermissionRow);

// Now that the rows are added to the relevant tables, create the template.
security.CreateTemplates(templateDs);

See Also

Reference

Security Class

Security Members

Security Web Service