简体   繁体   中英

Microsoft Graph userprincipalname C#

I am trying to auto increase the number after _ on userprincipalname but it dosen't works.

My code: https://gist.github.com/Erraticoye/b52e4e92102d80cc0349dbb297a93e79

Sorry for bad English. I tried try and catch(you can see in the code)

Had a quick look at your code. Seems you initialize the "i" variable in line 49 after a foreach loop.

Have you tried initializing the "i" variable at the beginning of your code and then have the foreach increment the value?

Or just move the int i = 2; before line 42 at least?

My guess is that the number is always 2 after the underscore.

If you are looking for the changing the password or updating it, the following code:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var currentPassword = "xWwvJ]6NMw+bWH-d";

var newPassword = "0eM85N54wFxWwvJ]";

await graphClient.Me
    .ChangePassword(currentPassword,newPassword)
    .Request()
    .PostAsync();

For more information: https://learn.microsoft.com/en-us/graph/api/user-changepassword?view=graph-rest-1.0&tabs=csharp#request

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM