How to reset password of user in Azure AD B2C via Graph API?

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How to reset password of user in Azure AD B2C via Graph API?



How to reset the password of the user using Microsoft Graph API?
Is there a way to do it? If yes, I am not able to find a way to do it.



Please let me know , How this can be achieved?
Thanks!




2 Answers
2



You can reset a user's password by PATCHing the user object:


PATCH https://graph.windows.net/myorganization/users/{user_id}?api-version=1.6

{
"passwordProfile": {
"password": "{password}",
"forceChangePasswordNextLogin": false
},
"passwordPolicies": "DisablePasswordExpiration"
}



For more information, see Reset a user's password.





Can we do this using client sdk (C#) of Microsoft Graph. I think the example that you have shared above is Microsoft AD Graph API
– prateek
Jun 12 at 10:33





As described by Azure AD B2C: Use the Azure AD Graph API, it is recommended that you use the Azure AD Graph API for managing users, including resetting a user's password.
– Chris Padgett
Jun 12 at 10:40



The approach suggested by Chris is the recommended.
As I wrote in this post (permissionissue) you should also take care of proper permission configuration as you can change the password from your application only if you give to it the right privilege.



In the Reset Password flow, is not possible to impersonate the user, because you doesn't have user's credentials, so you should grant admin privileges to the application that makes the call for other users.This implies you must trust the application's code and use it carefully.



I used to grant the Helpdesk Administrator role to my app which is enough to change password to other users.
Through this powershell script:


Install-Module MSOnline
Install-Module AzureAD
Connect-MsolService
Connect-AzureAD

$applicationId = "{your app ID}"
$sp = Get-MsolServicePrincipal -AppPrincipalId $applicationId
Add-MsolRoleMember -RoleObjectId <your Role ID> -RoleMemberObjectId $sp.ObjectId -RoleMemberType servicePrincipal



You should run this code using a User with Administrator Privileges on your Active Directory.
You can get the propert roleID using this command:


Get-AzureADDirectoryRole



Now your app has enough privileges to call the PATCH method to change the password for other users.





While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
– Umair
18 hours ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Fc o7rDoYl
DQ6OezzCY,mcvrt4tFUivoDKGN5 P83p,2EYAI6e

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham