Disable reversible password storage for SGU accounts
This commit is contained in:
1 parent
80baae1b54
commit
414a08ece6
9 files changed
+61
-46
No files matched your search
@@ -27,4 +27,5 @@ internal static class BrokerEventIds
|
||||
internal static readonly EventId DirectoryPasswordChangeDenied = new(1304, nameof(DirectoryPasswordChangeDenied));
|
||||
internal static readonly EventId DirectoryPhotoFailure = new(1305, nameof(DirectoryPhotoFailure));
|
||||
internal static readonly EventId DirectoryReversiblePasswordEncryptionEnabled = new(1306, nameof(DirectoryReversiblePasswordEncryptionEnabled));
|
||||
internal static readonly EventId DirectoryReversiblePasswordEncryptionDisabled = new(1307, nameof(DirectoryReversiblePasswordEncryptionDisabled));
|
||||
}
|
||||
@@ -132,10 +132,9 @@ public sealed class ActiveDirectorySynchronizer(
|
||||
// which ADSI SetPassword uses for each successful authentication.
|
||||
EnsureCannotChangePassword(user, identity.UserName);
|
||||
|
||||
// Scope reversible storage to users provisioned through SGU. The
|
||||
// group password policy requires it, and this account flag must be
|
||||
// set before the password is written.
|
||||
EnsureReversiblePasswordEncryption(user, identity.UserName);
|
||||
// Keep reversible storage disabled for SGU users. Clear the account
|
||||
// flag before writing the password so this reset uses one-way storage.
|
||||
EnsureReversiblePasswordEncryptionDisabled(user, identity.UserName);
|
||||
|
||||
// The exact institutional password received by the broker is passed to AD.
|
||||
// It is not derived, transformed, written to disk, or included in logs.
|
||||
@@ -181,20 +180,20 @@ public sealed class ActiveDirectorySynchronizer(
|
||||
institutionalUser);
|
||||
}
|
||||
|
||||
private void EnsureReversiblePasswordEncryption(DirectoryEntry user, string institutionalUser)
|
||||
private void EnsureReversiblePasswordEncryptionDisabled(DirectoryEntry user, string institutionalUser)
|
||||
{
|
||||
object? rawFlags = user.Properties["userAccountControl"].Value;
|
||||
int flags = rawFlags is null ? NormalAccount : Convert.ToInt32(rawFlags);
|
||||
if ((flags & ReversiblePasswordEncryptionAllowed) != 0)
|
||||
if ((flags & ReversiblePasswordEncryptionAllowed) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
user.Properties["userAccountControl"].Value = flags | ReversiblePasswordEncryptionAllowed;
|
||||
user.Properties["userAccountControl"].Value = flags & ~ReversiblePasswordEncryptionAllowed;
|
||||
user.CommitChanges();
|
||||
logger.LogInformation(
|
||||
BrokerEventIds.DirectoryReversiblePasswordEncryptionEnabled,
|
||||
"Enabled reversible password storage for SGU-managed Active Directory user {InstitutionalUser}.",
|
||||
BrokerEventIds.DirectoryReversiblePasswordEncryptionDisabled,
|
||||
"Disabled reversible password storage for SGU-managed Active Directory user {InstitutionalUser}.",
|
||||
institutionalUser);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user