password never expires fix
This commit is contained in:
parent
dde62638b2
commit
2f1e740d5a
1 changed files with 23 additions and 0 deletions
|
@ -693,6 +693,11 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
string groupPath = GetGroupPath(organizationId);
|
string groupPath = GetGroupPath(organizationId);
|
||||||
|
|
||||||
SetFineGrainedPasswordPolicySubject(runspace, groupPath, psoName);
|
SetFineGrainedPasswordPolicySubject(runspace, groupPath, psoName);
|
||||||
|
|
||||||
|
if (settings.MaxPasswordAge == 0)
|
||||||
|
{
|
||||||
|
SetPasswordNeverExpiresInFineGrainedPasswordPolicy(runspace, psoName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -711,6 +716,24 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
return string.Format("{0}-PSO", organizationId);
|
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)
|
private bool FineGrainedPasswordPolicyExist(Runspace runspace, string psoName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue