Add branded default provider and enforced enrollment

This commit is contained in:
2026-09-01 11:20:06 -06:00
parent da01343985
commit f3afd62993
22 changed files with 787 additions and 17 deletions
@@ -85,6 +85,11 @@ public sealed class BrokerOptions
{
throw new InvalidOperationException("RemoteDesktopGroupDn must identify a group beneath BaseDn.");
}
if (string.IsNullOrWhiteSpace(Directory.DefaultCompany) || Directory.DefaultCompany.Length > 64)
{
throw new InvalidOperationException("DefaultCompany is required and must not exceed 64 characters.");
}
}
private static bool IsCertificateThumbprint(string value)
@@ -139,6 +144,8 @@ public sealed class ActiveDirectoryOptions
public string RemoteDesktopGroupDn { get; init; } = string.Empty;
public string DefaultCompany { get; init; } = "Universidad La Salle";
public bool CreateMissingOus { get; init; }
public string GetOuDn(InstitutionalRole role) => role switch
@@ -100,7 +100,7 @@ public sealed class ActiveDirectorySynchronizer(BrokerOptions options) : IActive
user.Properties["pwdLastSet"].Value = -1;
user.CommitChanges();
TryApplyProfile(user, identity, profile);
TryApplyProfile(user, identity, profile, options.DefaultCompany);
TryEnsureRemoteDesktopGroupMembership(user);
return new DirectorySyncResult(
@@ -119,23 +119,23 @@ public sealed class ActiveDirectorySynchronizer(BrokerOptions options) : IActive
private static void TryApplyProfile(
DirectoryEntry user,
UserIdentity identity,
InstitutionalProfile? profile)
InstitutionalProfile? profile,
string defaultCompany)
{
if (profile is null)
{
return;
}
try
{
SetOptionalProperty(user, "displayName", profile.DisplayName);
SetOptionalProperty(user, "mail", profile.Email);
SetOptionalProperty(user, "title", profile.JobTitle);
SetOptionalProperty(user, "department", profile.Department);
SetOptionalProperty(user, "employeeType", profile.EmployeeType);
if (string.Equals(profile.EmployeeNumber, identity.NumericId, StringComparison.Ordinal))
SetOptionalProperty(user, "company", defaultCompany);
if (profile is not null)
{
SetOptionalProperty(user, "employeeID", profile.EmployeeNumber);
SetOptionalProperty(user, "displayName", profile.DisplayName);
SetOptionalProperty(user, "mail", profile.Email);
SetOptionalProperty(user, "title", profile.JobTitle);
SetOptionalProperty(user, "department", profile.Department);
SetOptionalProperty(user, "employeeType", profile.EmployeeType);
if (string.Equals(profile.EmployeeNumber, identity.NumericId, StringComparison.Ordinal))
{
SetOptionalProperty(user, "employeeID", profile.EmployeeNumber);
}
}
user.CommitChanges();
+1
View File
@@ -47,6 +47,7 @@
"StudentOuDn": "OU=Alumnos,OU=Usuarios-SGU,DC=lci,DC=lasalle,DC=mx",
"AdministrativeOuDn": "OU=Administrativos,OU=Usuarios-SGU,DC=lci,DC=lasalle,DC=mx",
"RemoteDesktopGroupDn": "",
"DefaultCompany": "Universidad La Salle",
"CreateMissingOus": false
}
}