Azure Graph API transaction

jubing long 121 Reputation points
2022-01-28T08:55:02.17+00:00

Hello,

I using Azure AD(free) to store user login information.
When I want change user's password in my application by application way(appID, appSecurity).
But changePassword not support application way.
So I send two graph api: first delete user, second add user.
But how can I keep the two times call all success or all failure. (in a transaction)
User user = graphServiceClient.users(id).buildRequest().get();
// first : delete the user
graphServiceClient.users(id).buildRequest().delete(user);

// second: add user
PasswordProfile passwordProfile = new PasswordProfile();
passwordProfile.forceChangePasswordNextSignIn = true;
passwordProfile.password = "Abc,123.";
user.passwordProfile = passwordProfile;
graphServiceClient.users(id).buildRequest().post(userInfo);

Best wishes.

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
13,579 questions
{count} votes

Accepted answer
  1. James Hamil 12,976 Reputation points Microsoft Employee
    2022-02-01T22:18:20.477+00:00

    Hi @jubing long , your workaround method seems a bit complicated. We should try to get changePassword working for you instead. Have you made sure that you have the appropriate permissions for this?

    Directory.AccessAsUser.All  
    

    Unless you're using the unsupported types, which I assume you are? Are you just trying to change the users passwords? Have you looked into SSPR? If not, please let me know what your use case is and I can find a better solution for you.

    Best,
    James


0 additional answers

Sort by: Most helpful