Sunday, June 2, 2019

Web Services (SuiteTalk) : C# .Net Sample> Change Password

Use the changePassword operation to change a user's password. Below is a sample code demonstration how to change password using C#

Sample Code (C#)

public void changePasswordFunc()

        {

            NetSuiteService service = new NetSuiteService();

            LoginClass passport = new LoginClass();//User Defined/Created Class to hold login credential

            service.passport = passport.login();

 

            ChangePassword changePassword = new ChangePassword();

            changePassword.currentPassword = "Test123456";

            changePassword.newPassword = "Test654321";

            changePassword.newPassword2 = "Test654321";

            changePassword.justThisAccount = true;

 

            SessionResponse response = service.changePassword(changePassword);

 

            if (response.status.isSuccess)

            {

                Console.WriteLine("Password have been Successful Changed");

            }

            else

            {

                StatusDetail[] statusDetail = response.status.statusDetail;

                for (var x = 0; x < response.status.statusDetail.Length; x++)

                {

                    Console.WriteLine(statusDetail[x].code);

                    Console.WriteLine(statusDetail[x].type + ": " +statusDetail[x].message);

                }

            }

            Console.ReadLine();

        }

No comments:

Post a Comment