Exemple #1
0
    protected void Submit_UserModify(object sender, EventArgs e)
    {
        //Create a new client to store authentication
        RestClient authenticationClient = UiDrivenLogin.Authenticate(TenantUrl, AdminServiceAccount);
        //Parse result challenge list. This is a service account so we can assume the results will be password and that there will only be one result.
        Dictionary <string, dynamic> mech = authenticationClient.ChallengeCollection[0]["Mechanisms"][0];

        //Login for service account is assumed to only require password and no MFA.
        if (mech["AnswerType"] == "Text")
        {
            //Call advance authentication with our service account credentials
            UiDrivenLogin.AdvanceForMech(authenticationClient, authenticationClient.TenantId, authenticationClient.SessionId, true, mech, null, AdminServicePass);
        }
        //Something other then text was returned which indicates that the service account is not set up correctly.
        else
        {
            FailureText.Text     = "The service account is not set up correctly. It should only require a password an no MFA.";
            ErrorMessage.Visible = true;

            UserInfo_div.Visible        = false;
            MyAccount_Start_div.Visible = false;
        }

        //Create a new userManagementClient and pass our authenticated rest client from our login call.
        UserManagement userManagementClient = new UserManagement(authenticationClient);
        CDUser         cUser = new CDUser();

        cUser.Name         = LoginName.Text + "@" + Alias_DropDownList.SelectedItem.ToString();
        cUser.ID           = UserUUID.Text;
        cUser.DisplayName  = DisplayName.Text;
        cUser.Mail         = Email.Text;
        cUser.OfficeNumber = OfficeNumber.Text;
        cUser.MobileNumber = MobileNumber.Text;
        cUser.HomeNumber   = HomeNumber.Text;

        Dictionary <string, dynamic> modifyUserResult = userManagementClient.ChangeUser(cUser, InEverybodyRole.Checked);

        if (modifyUserResult["success"])
        {
            SuccessText.Text       = "User " + LoginName.Text + " was successfully modified.";
            SuccessMessage.Visible = true;

            //hide unneeded elements.
            UserInfo_div.Visible        = false;
            MyAccount_Start_div.Visible = false;
        }
        else
        {
            FailureText.Text     = "There was an error modifying the user: "******"Message"];
            ErrorMessage.Visible = true;

            //hide unneeded elements.
            UserInfo_div.Visible        = false;
            MyAccount_Start_div.Visible = false;
        }
    }
    protected void Submit_UserModify(object sender, EventArgs e)
    {
        //Pull authentication client from session
        RestClient authenticationClient = (RestClient)Session["AuthenticaitonClient"];

        //Create a new userManagementClient and pass our authenticated rest client from our login call.
        UserManagement userManagementClient = new UserManagement(authenticationClient);
        CDUser         cUser = new CDUser();

        cUser.ID           = UserUUID.Text;
        cUser.Name         = LoginName.Text + "@" + Alias_DropDownList.SelectedItem.ToString();
        cUser.DisplayName  = DisplayName.Text;
        cUser.Mail         = Email.Text;
        cUser.OfficeNumber = OfficeNumber.Text;
        cUser.MobileNumber = MobileNumber.Text;
        cUser.HomeNumber   = HomeNumber.Text;

        Dictionary <string, dynamic> modifyUserResult = userManagementClient.ChangeUser(cUser, InEverybodyRole.Checked);

        if (modifyUserResult["success"])
        {
            SuccessText.Text       = "User " + LoginName.Text + " was successfully modified.";
            SuccessMessage.Visible = true;

            //hide unneeded elements.
            ModifyUser_div.Visible           = false;
            UserInfo_div.Visible             = false;
            Modify_Submit_Button_Div.Visible = false;
        }
        else
        {
            FailureText.Text = "There was an error modifying the user: "******"Message"];

            //hide unneeded elements.
            ErrorMessage.Visible             = true;
            ModifyUser_div.Visible           = false;
            UserInfo_div.Visible             = false;
            Modify_Submit_Button_Div.Visible = false;
        }
    }