Aspose.Tasks for C++
ProjectServerCredentials.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="ProjectServerCredentials.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/string.h>
9 
10 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
11 
12 namespace Aspose
13 {
14 namespace Tasks
15 {
16 namespace IO
17 {
18 namespace Pwa
19 {
20 class ProjectServerConnection;
21 } // namespace Pwa
22 } // namespace IO
23 } // namespace Tasks
24 } // namespace Aspose
25 namespace System
26 {
27 namespace Net
28 {
29 class NetworkCredential;
30 } // namespace Net
31 } // namespace System
32 
33 namespace Aspose {
34 
35 namespace Tasks {
36 
37 /// <summary>
38 /// Credentials which are used to connect to Project Online or on-premise instance of Project Server.
39 /// </summary>
40 class ASPOSE_TASKS_SHARED_CLASS ProjectServerCredentials final : public System::Object
41 {
43  typedef System::Object BaseType;
44 
45  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
46  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
47 
48  friend class Aspose::Tasks::IO::Pwa::ProjectServerConnection;
49 
50 public:
51 
52  /// <summary>
53  /// Gets the URL of PWA at SharePoint site or URL of on-premise Project Server.
54  /// For example, https://your_company_name.sharepoint.com/sites/pwa";
55  /// </summary>
56  ASPOSE_TASKS_SHARED_API System::String get_SiteUrl() const;
57  /// <summary>
58  /// Gets the authorization token for the SharePoint instance.
59  /// </summary>
60  ASPOSE_TASKS_SHARED_API System::String get_AuthToken() const;
61  /// <summary>
62  /// Gets the user name for SharePoint site.
63  /// </summary>
64  ASPOSE_TASKS_SHARED_API System::String get_UserName() const;
65 
66  /// <summary>
67  /// Initializes a new instance of the <see cref="ProjectServerCredentials"></see> class using URL of SharePoint site and valid SPOIDCRL authorization token for SharePoint's PWA (Project Web Access) site.
68  /// </summary>
69  /// <param name="siteUrl">The URL of PWA (Project Web Access) API of Project Online.</param>
70  /// <param name="authToken">The authorization token (SPOIDCRL) for SharePoint's PWA (Project Web Access) site.</param>
71  /// <remarks>Use this constructor to connect to ProjectOnline when you already have AuthToken for your SharePoint Online site.</remarks>
72  ASPOSE_TASKS_SHARED_API ProjectServerCredentials(const System::String& siteUrl, const System::String& authToken);
73  /// <summary>
74  /// Initializes a new instance of the <see cref="ProjectServerCredentials"></see> class using URL of SharePoint site, user name and password.
75  /// </summary>
76  /// <param name="siteUrl">The URL of PWA (Project Web Access) API of Project Online.</param>
77  /// <param name="userName">The user name for the SharePoint site.</param>
78  /// <param name="password">The password for the SharePoint site.</param>
79  /// <remarks>Use this constructor to connect to ProjectOnline. Please note that legacy authentication should be enabled in your Azure portal and Office 365 Admin center.</remarks>
80  ASPOSE_TASKS_SHARED_API ProjectServerCredentials(const System::String& siteUrl, const System::String& userName, const System::String& password);
81  /// <summary>
82  /// Initializes a new instance of the <see cref="ProjectServerCredentials"></see> class using URL of Project Web Access endpoint and network credentials.
83  /// </summary>
84  /// <param name="siteUrl">The URL of project web access endpoint.</param>
85  /// <param name="credentials">The credentials used to login to Project Web Access endpoint.</param>
86  /// <remarks>Use this constructor to connect to on-premise instance of Project Server via PWA.</remarks>
87  /// <example>
88  /// In this example the instance of <see cref="ProjectServerManager"></see> class is used to read a list of project from Project Server instance located at http://project_server_instance.local
89  /// <code>
90  /// string site = "http://project_server_instance.local/sites/pwa";
91  /// var windowsCredentials = new NetworkCredential("Administrator", "my_password", "DOMAIN");
92  /// var projectServerCredentials = new ProjectServerCredentials(site, windowsCredentials);
93  /// ProjectServerManager manager = new ProjectServerManager(projectServerCredentials);
94  ///
95  /// var list = manager.GetProjectList();
96  /// foreach (var projectInfo in list)
97  /// {
98  /// Console.WriteLine("{0} - {1} - {2}", projectInfo.Id, projectInfo.CreatedDate, projectInfo.Name);
99  /// }
100  /// </code>
101  /// </example>
102  ASPOSE_TASKS_SHARED_API ProjectServerCredentials(const System::String& siteUrl, const System::SharedPtr<System::Net::NetworkCredential>& credentials);
103 
104  /// <summary>
105  /// Returns a string representation of this instance.
106  /// </summary>
107  /// <returns>a string representation of this instance.</returns>
108  ASPOSE_TASKS_SHARED_API System::String ToString() const override;
109 
110 protected:
111 
112  /// <summary>
113  /// Gets the authorization token for the SharePoint instance.
114  /// </summary>
115  ASPOSE_TASKS_SHARED_API void set_AuthToken(const System::String& value);
116  ASPOSE_TASKS_SHARED_API System::String get_Password() const;
117  ASPOSE_TASKS_SHARED_API void set_Password(const System::String& value);
118  ASPOSE_TASKS_SHARED_API const System::SharedPtr<System::Net::NetworkCredential>& get_NtlmCredentials() const;
119  ASPOSE_TASKS_SHARED_API bool get_IsProjectOnlineCredentials();
120 
121  #ifdef ASPOSE_GET_SHARED_MEMBERS
122  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
123  #endif
124 
125 
126 private:
127 
128  System::String pr_SiteUrl;
129 
130  /// <summary>
131  /// Gets the URL of PWA at SharePoint site or URL of on-premise Project Server.
132  /// For example, https://your_company_name.sharepoint.com/sites/pwa";
133  /// </summary>
134  ASPOSE_TASKS_SHARED_API void set_SiteUrl(const System::String& value);
135 
136  System::String pr_AuthToken;
137  System::String pr_UserName;
138 
139  /// <summary>
140  /// Gets the user name for SharePoint site.
141  /// </summary>
142  ASPOSE_TASKS_SHARED_API void set_UserName(const System::String& value);
143 
144  System::String pr_Password;
145  System::SharedPtr<System::Net::NetworkCredential> pr_NtlmCredentials;
146 
147  ASPOSE_TASKS_SHARED_API void set_NtlmCredentials(const System::SharedPtr<System::Net::NetworkCredential>& value);
148 
149 };
150 
151 } // namespace Tasks
152 } // namespace Aspose
153 
154 
Credentials which are used to connect to Project Online or on-premise instance of Project Server...
Definition: ProjectServerCredentials.h:40