Office 365
の資格情報を使用してユーザーがWebサイトにログインしたときにユーザープロファイルデータを取得するためにpowershell
コマンドを使用しています。 4人から6人のユーザーが私のウェブサイトにアクセスしてoffice 365
のログインボタンを押すと、問題が発生しています。これらの資格情報をpowershell
に渡すと、3人のユーザーセッションが作成されますが、私は自分自身をgoogledし、同じことを述べるリンクを見つけた。ここにリンクがある:私は一度に私のウェブサイトへの複数のユーザーを期待する必要があるとして、asp.netの電源シェルコマンドを使用してOffice 365のプロファイルデータを取得しようとする複数のユーザー
私はこのための任意の解像度を持つことができます。ここで
私のサンプルコードは次のとおりです。
try
{
Collection<PSObject> userList = null;
// Create Initial Session State for runspace.
InitialSessionState initialSession = InitialSessionState.CreateDefault();
initialSession.ImportPSModule(new[] { "MSOnline" });
// Create credential object.
PSCredential credential = new PSCredential(UserCredential.UserName, UserCredential.Password);
// Create command to connect office 365.
Command connectCommand = new Command("Connect-MsolService");
connectCommand.Parameters.Add((new CommandParameter("Credential", credential)));
Command getUserCommand = new Command("Get-MsolUser");
getUserCommand.Parameters.Add((new CommandParameter("UserPrincipalName", UserCredential.UserName)));
using (Runspace psRunSpace = RunspaceFactory.CreateRunspace(initialSession))
{
// Open runspace.
psRunSpace.Open();
//Iterate through each command and executes it.
foreach (var com in new Command[] { connectCommand, getUserCommand })
{
var pipe = psRunSpace.CreatePipeline();
pipe.Commands.Add(com);
// Execute command and generate results and errors (if any).
Collection<PSObject> results = pipe.Invoke();
var error = pipe.Error.ReadToEnd();
if (error.Count > 0 && com == connectCommand)
{
// MessageBox.Show(error[0].ToString(), "Problem in login");
//this.Close();
return null;
}
if (error.Count > 0 && com == getUserCommand)
{
// MessageBox.Show(error[0].ToString(), "Problem in getting users");
// this.Close();
return null;
}
else
{
userList = results;
Session["office365userslist"] = userList;
}
}
// Close the runspace.
psRunSpace.Close();
}
return userList;
}
catch (Exception ex)
{
Response.Write(ex.Message);
throw;
}
おかげチェン、我々はパワーシェルを使用して免責HTMLを設定しています。だから私はすべてのコードをパワーシェルで書いた。 APIを使用して交換サーバーに免責文を追加する方法はありますか? –
グラフAPIは免責条項htmlを設定する機能を提供していません。この場合、可能な回避策がリクエストの順序を決めている可能性があります。 –
こんにちはChen。私はちょうど私のサンプルコードを更新します。それを一度チェックしてください。私はシーケンスとしてそれを作ることができますか?あなたはどうすればいいですか? –