MFA が有効になっているクライアントのために、CSOM/C# を介して Project Onine と対話したいと考えています。以下のスニペットを使用すると、sharepoint MFA を通過できると思います (デバッガーはこれらの行を通過します) が、Project Online のコンテキストを取得するにはどうすればよいでしょうか? へのキャストが失敗します (エラー メッセージから、その理由は理解できると思います)。
private static bool GetMultiFactorAuthCookie(string pwaPath)
{
bool error = false;
var authManager = new AuthenticationManager();
ClientContext sharepointClientContext = authManager.GetWebLoginClientContext(pwaPath);
web = sharepointClientContext.Web;
user = web.CurrentUser;
sharepointClientContext.Load(web);
sharepointClientContext.Load(user);
sharepointClientContext.ExecuteQuery();
ProjectContext projContext = sharepointClientContext.CastTo<ProjectContext>(sharepointClientContext);
return !error;
}
デバッガーが教えてくれます
「Microsoft.SharePoint.Client.ClientContext」から「Microsoft.SharePoint.Client.ClientObject」に変換できません