protected void btnUpdateExpirationDate_Click(object sender, EventArgs e)
{
this.PanelPasswordHistory.Visible = false;
_Default defaultPage = (_Default)this.Page;
DateTime newExpirationDate;
if (!DateTime.TryParse(textUpdateExpirationDateNewValue.Text, out newExpirationDate))
{
this.PanelResult.Visible = true;
this.labelResult.Text = Messages.RC_NotValidExpirationDate;
this.PanelResult.CssClass = "errorMessage";
}
else
{
PasswordResetStatus rslt = null;
var current = System.Security.Principal.WindowsIdentity.GetCurrent();
using (WindowsImpersonationContext wic = ((WindowsIdentity)Page.User.Identity).Impersonate())
{
try
{
rslt = PDSUtils.PdsWrapper.ResetPassword(this.cboForestNames.Text, this.textComputerName.Text, newExpirationDate.ToUniversalTime());
}
catch (System.ServiceModel.FaultException<ServiceFault> faex)
{
switch(faex.Detail.IssueCode)
{
case IssueType.ComputerNotFound:
this.labelResult.Text = Messages.Errors_ADNoComputerFoundException + " " + faex.Message;
this.PanelResult.CssClass = "errorMessage";
break;
case IssueType.ComputerAmbiguous:
this.labelResult.Text = Messages.Errors_MultipleComputerObjectsFound + ": " + faex.Message;
break;
case IssueType.AccessDenied:
this.labelResult.Text = Messages.Errors_NoResetPasswordForUserOnComputerObject + ": " + faex.Message;
break;
case IssueType.CannotResetPassword:
this.labelResult.Text = Messages.Errors_CannotResetPassword + ": " + faex.Message;
break;
default:
this.labelResult.Text = Messages.Errors_CannotResetPassword + ": " + faex.Message;
break;
}
this.PanelResult.CssClass = "errorMessage";
this.PanelResult.Visible = true;
defaultPage.ShowBackToNewRequestButton();
return;
}
catch (Exception ex)
{
labelResult.Text = Messages.Errors_ServiceNotAvailable + " - " + ex.Message;
this.PanelResult.CssClass = "errorMessage";
PanelResult.Visible = true;
defaultPage.ShowBackToNewRequestButton();
return;
}
}
current = System.Security.Principal.WindowsIdentity.GetCurrent();
PanelExpirationDateChange.Visible = false;
textAdminPasswordExpiration.Text = newExpirationDate.ToString();
this.PanelPasswordHistory.Visible = false;
this.PanelResult.Visible = true;
this.labelResult.Text = Messages.RC_ExpirationDateUpdated;
this.PanelResult.CssClass = "okMessage";
defaultPage.ShowBackToNewRequestButton();
}
}