私は、紺碧のADとグラフのAPIについては、特定の質問があります。Azure ADでは、一時パスワードを使用してパスワードの変更要求を送信するにはどうすればよいですか?
私はAPIに簡単なパスワード変更要求をしています。これは、ユーザーがログインできるときに機能しますが、ユーザーがポータルを介して一時パスワードにパスワードをリセットした場合、次にログインするときにパスワードを変更する必要があります。私は、パスワード変更要求を送信することが出来るのですか、私は認証トークンを取得することができないのであれば
AADSTS50055: Force Change Password.
:私はこれを持っている問題は、ときに例外が返され、そのユーザーの認証トークンを取得しようとしていますユーザーが自分のアプリ内で自分のパスワードを変更できるようにGraph APIを使用していますか?以下は
は、すでにログインすることができ、ユーザーにパスワードを変更するための私のコードです:
public SendPasswordChangeRequest(string userId, string newPass, string oldPass) {
try {
HttpClient http = new HttpClient();
string action = string.Format("https://stackoverflow.com/users/{0}/changePassword", user.DistinguishedName);
string url = string.Format("https://graph.windows.net/{0}{1}?api-version=1.6", tenantId, action);
object bodyObject = new { currentPassword = oldPass, newPassword = newPass };
string body = JsonConvert.SerializeObject(bodyObject);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Content = new StringContent(body, Encoding.UTF8, "application/json");
AuthenticationContext authContext = new AuthenticationContext(string.Format("https://login.windows.net/{0}", tenantName));
UserPasswordCredential credential = new UserPasswordCredential(userId, oldPass); //userId and oldPass are parameters passed in
AuthenticationResult authResult = authContext.AcquireTokenAsync("https://graph.windows.net/", clientId, credential).Result;
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
HttpResponseMessage httpResponse = http.SendAsync(request).Result;
}
catch (Exception ex) {
//authResult throws the error into here
//Error returned from Azure AD:
//AADSTS50055: Force Change Password.
}
}
ありがとうございます!それは私が恐れていたものです。うまくいけば、この答えは他の人が同じ質問をするのを助けてくれるはずです。 – YourbrainonCompSci