password never expires fix

This commit is contained in:
vfedosevich 2015-04-29 07:36:48 -07:00
parent dde62638b2
commit 2f1e740d5a

View file

@ -693,6 +693,11 @@ namespace WebsitePanel.Providers.HostedSolution
string groupPath = GetGroupPath(organizationId);
SetFineGrainedPasswordPolicySubject(runspace, groupPath, psoName);
if (settings.MaxPasswordAge == 0)
{
SetPasswordNeverExpiresInFineGrainedPasswordPolicy(runspace, psoName);
}
}
catch (Exception ex)
{
@ -711,6 +716,24 @@ namespace WebsitePanel.Providers.HostedSolution
return string.Format("{0}-PSO", organizationId);
}
private void SetPasswordNeverExpiresInFineGrainedPasswordPolicy(Runspace runspace, string psoName)
{
var psoObject = GetFineGrainedPasswordPolicy(runspace, psoName);
var distinguishedName = GetPSObjectProperty(psoObject, "DistinguishedName") as string;
var cmd = new Command("Set-ADObject");
cmd.Parameters.Add("Identity", distinguishedName);
var hashTable = new Hashtable();
hashTable.Add("msDS-MaximumPasswordAge", "-9223372036854775808");
cmd.Parameters.Add("Replace", hashTable);
ExecuteShellCommand(runspace, cmd);
}
private bool FineGrainedPasswordPolicyExist(Runspace runspace, string psoName)
{
try