次の方法で共有


Security.CreateProjectCategories メソッド

Web セキュリティのためのプロジェクトのカテゴリを作成します。

名前空間:  WebSvcSecurity
アセンブリ:  ProjectServerServices (ProjectServerServices.dll 内)

構文

'宣言
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Security/CreateProjectCategories", 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 CreateProjectCategories ( _
    categories As SecurityProjectCategoriesDataSet _
)
'使用
Dim instance As Security
Dim categories As SecurityProjectCategoriesDataSet

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

パラメーター

注釈

機能は、プロジェクトのアクセス許可ではユーザーまたはグループが所有するプロジェクトをユーザーとグループのアクセスを許可するには、「基本プロジェクト セキュリティの管理」カテゴリのアクセス許可が与えられていますいます。セキュリティ カテゴリのような機能です。詳細については、 https://blogs.msdn.com/b/project/archive/2010/03/04/project-2010-project-permissions.aspx

プロジェクト サーバーのアクセス許可

[アクセス許可]

0e81566c-99cb-e77e-a217-99e78de7db31_summary

標準的でないです。

ManageWorkflowのグローバル アクセス権、または、 ChangeWorkflowのグローバル アクセス許可が必要です。ChangeWorkflowアクセス許可があれば、 OpenProjectカテゴリ権限とSaveProjectカテゴリのアクセス権の両方もが必要です。

例では、ProjectServerServices.dll プロキシ アセンブリ内のSvcSecurityの名前空間を使用します。ConfigureClientEndPointsメソッドは、WCF のバインディング、動作、およびエンドポイントの設定を app.config ファイルを使用します。PSI プロキシ アセンブリと app.config ファイルを作成する方法の詳細については、 Project 2013 での WCF ベースのコード サンプルの前提条件を参照してください。

注意

次の使用例はプロジェクトがどのカテゴリに割り当てられていないことを前提としています。

例では、プロジェクトの一覧を取得するには、 ReadProjectListメソッドを呼び出します。書き込む XML ファイルのCategories.xmlを次のコードに示すように、 ProjectCategoriesDatasetを作成するCreateProjectCategoriesを呼び出します。

<?xml version="1.0" standalone="yes"?>
<SecurityProjectCategoriesDataSet xmlns="https://schemas.microsoft.com/office/project/server/
webservices/SecurityProjectCategoriesDataSet/">
  <ProjectCategories>
    <WSEC_CAT_UID>
    321f7584-1f8b-4065-a432-a59b9412d8ba</WSEC_CAT_UID>
    <PROJ_UID>ff9c1198-fb7b-4e9d-88a9-1415d46a3443</PROJ_UID>
  </ProjectCategories>
</SecurityProjectCategoriesDataSet>

UpdateProjectCategoriesメソッドは、 ProjectCategoriesDatasetを更新します。次のスニペットで示すように、更新されたデータセットは、 UpdatedCategories.xmlファイルに書き込まれます。

<?xml version="1.0" standalone="yes"?>
<SecurityProjectCategoriesDataSet xmlns="https://schemas.microsoft.com/office/project/server/
webservices/SecurityProjectCategoriesDataSet/">
  <ProjectCategories>
    <WSEC_CAT_UID>
     8ce0a52b-6218-4670-bf53-8e8df21af590</WSEC_CAT_UID>
    <PROJ_UID>aed0e69b-4470-4ddb-b063-184a9c06c9de</PROJ_UID>
  </ProjectCategories>
</SecurityProjectCategoriesDataSet>

DeleteProjectCategoriesメソッドはプロジェクト Guid の配列を受け取るし、 ProjectCategoriesDataset内のエントリを削除します。完全なサンプル コードを次に示します。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;

namespace Microsoft.SDK.Project.Samples.Security
{
    class Security
    {
        private const string ENDPOINT_S = "basicHttp_Security";
        private const string ENDPOINT_P = "basicHttp_Project";
        private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";

        private static string outFilePathCategories;
        private static string outFilePathUpdatedCategories;

        private static SvcSecurity.SecurityClient securityClient;
        private static SvcProject.ProjectClient projectClient;

        static void Main(string[] args)
        {
            // If directory does not exist, create it.
            if (!Directory.Exists(OUTPUT_FILES))
            {
                Directory.CreateDirectory(OUTPUT_FILES);
            }
            // Assign the path where the output XML file will be saved.
            outFilePathCategories = OUTPUT_FILES + "Categories.xml";
            outFilePathUpdatedCategories = OUTPUT_FILES + "UpdatedCategories.xml";

            // Configure the endpoints.
            bool configResult = false;
            configResult = ConfigClientEndpoints(ENDPOINT_P);
            configResult = ConfigClientEndpoints(ENDPOINT_S);

            try
            {
                // Create a project DataSet.
                SvcProject.ProjectDataSet pDS = new SvcProject.ProjectDataSet();
                pDS = projectClient.ReadProjectList();

                // Create a project category.
                SvcSecurity.SecurityProjectCategoriesDataSet projectCategoryDataSet1 = 
                    new SvcSecurity.SecurityProjectCategoriesDataSet();
                SvcSecurity.SecurityProjectCategoriesDataSet.ProjectCategoriesRow row1 = 
                    projectCategoryDataSet1.ProjectCategories.NewProjectCategoriesRow();
                row1.WSEC_CAT_UID = Guid.NewGuid();
                row1.PROJ_UID = pDS.Project[2].PROJ_UID;
                projectCategoryDataSet1.ProjectCategories.AddProjectCategoriesRow(row1);
                securityClient.CreateProjectCategories(projectCategoryDataSet1);

                // Read project category DataSet.
                SvcSecurity.SecurityProjectCategoriesDataSet projectCategoryDataSet = 
                    securityClient.ReadProjectCategory(row1.PROJ_UID);

                // Write the project category DataSet to an XML file.
                Console.WriteLine("\nWriting the ProjectCategoryDataSet to an XML file...");
                projectCategoryDataSet.WriteXml(outFilePathCategories);
                Console.WriteLine("\nSee XML output of ProjectCategoryDataSet at {0}",
                outFilePathCategories);
                Console.Write("\nPress any key to continue: ");
                Console.ReadKey(true);

                // Update project category DataSet.
                SvcSecurity.SecurityProjectCategoriesDataSet projectCategoryDataSet3 = 
                    new SvcSecurity.SecurityProjectCategoriesDataSet();
                SvcSecurity.SecurityProjectCategoriesDataSet.ProjectCategoriesRow row2 = 
                    projectCategoryDataSet3.ProjectCategories.NewProjectCategoriesRow();
                row2.WSEC_CAT_UID = Guid.NewGuid();
                row2.PROJ_UID = pDS.Project[3].PROJ_UID;
                projectCategoryDataSet3.ProjectCategories.AddProjectCategoriesRow(row2);
                securityClient.UpdateProjectCategories(projectCategoryDataSet3);

                // Read project category DataSet.
                SvcSecurity.SecurityProjectCategoriesDataSet updatedPDS = 
                    securityClient.ReadProjectCategory(row2.PROJ_UID);

                // Write the updated project category DataSet to an XML file.
                Console.WriteLine("\nWriting the ProjectCategoryDataSet to an XML file...");
                updatedPDS.WriteXml(outFilePathUpdatedCategories);
                Console.WriteLine("\nSee XML output of ProjectCategoryDataSet at {0}",
                outFilePathUpdatedCategories);
                Console.Write("\nPress any key to continue: ");
                Console.ReadKey(true);

                // Delete project categories.
                Guid[] guidarray = new Guid[2];
                guidarray[0] = row1.PROJ_UID;
                guidarray[1] = row2.PROJ_UID;
                securityClient.DeleteProjectCategories(guidarray);
            }
            catch (CommunicationException e)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(
                    "\n***System.ServiceModel.CommunicationException:");
                Console.WriteLine(e.ToString());
                Console.ResetColor();
            }
            
        }

        // Configure the PSI client endpoints.
        public static bool ConfigClientEndpoints(string endpt)
        {
            bool result = true;

            switch (endpt)
            {

                case ENDPOINT_P:
                    projectClient = new SvcProject.ProjectClient(endpt);
                    break;
                case ENDPOINT_S:
                    securityClient = new SvcSecurity.SecurityClient(endpt);
                    break;
                default:
                    result = false;
                    Console.WriteLine("Invalid endpoint: {0}", endpt);
                    break;
            }
            return result;
        }
       

    }
}

関連項目

参照先

Security クラス

Security メンバー

WebSvcSecurity 名前空間