Add branded default provider and enforced enrollment
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ internal static class ControlKeys
|
||||
{
|
||||
public const string ProviderLabel = "ProviderLabel";
|
||||
public const string ProviderLogo = "ProviderLogo";
|
||||
public const string UserTile = "UserTile";
|
||||
public const string Heading = "Heading";
|
||||
public const string InformationLabel = "InformationLabel";
|
||||
public const string UserName = "UserName";
|
||||
public const string Password = "Password";
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace SGU.CredentialProvider;
|
||||
internal static class ProviderTileIcon
|
||||
{
|
||||
public const int Size = 72;
|
||||
public const int UserTileSize = 128;
|
||||
|
||||
public static Bitmap Create()
|
||||
{
|
||||
@@ -30,4 +31,29 @@ internal static class ProviderTileIcon
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Bitmap CreateUserTile()
|
||||
{
|
||||
Bitmap bitmap = new(UserTileSize, UserTileSize, PixelFormat.Format32bppArgb);
|
||||
using Graphics graphics = Graphics.FromImage(bitmap);
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
graphics.Clear(Color.FromArgb(0, 83, 155));
|
||||
|
||||
using Pen border = new(Color.FromArgb(190, 221, 241), 5f);
|
||||
using Pen key = new(Color.White, 9f)
|
||||
{
|
||||
StartCap = LineCap.Round,
|
||||
EndCap = LineCap.Round,
|
||||
LineJoin = LineJoin.Round
|
||||
};
|
||||
|
||||
graphics.DrawEllipse(border, 7, 7, 113, 113);
|
||||
graphics.DrawEllipse(key, 25, 25, 43, 43);
|
||||
graphics.DrawLine(key, 62, 62, 99, 99);
|
||||
graphics.DrawLine(key, 82, 82, 95, 69);
|
||||
graphics.DrawLine(key, 93, 93, 106, 80);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,18 @@ public sealed class SguCredentialProvider : CredentialProviderBase
|
||||
|
||||
public override IEnumerable<ControlBase> GetControls(UsageScenario cpus)
|
||||
{
|
||||
yield return new CredentialProviderLabelControl(ControlKeys.ProviderLabel, "Acceso institucional SGU");
|
||||
yield return new CredentialProviderLabelControl(
|
||||
ControlKeys.ProviderLabel,
|
||||
"Universidad La Salle · Acceso SGU");
|
||||
yield return new CredentialProviderLogoControl(
|
||||
ControlKeys.ProviderLogo,
|
||||
"Acceso institucional SGU",
|
||||
ProviderTileIcon.Create());
|
||||
yield return new UserTileControl(
|
||||
ControlKeys.UserTile,
|
||||
"Universidad La Salle",
|
||||
ProviderTileIcon.CreateUserTile());
|
||||
yield return new LargeLabelControl(ControlKeys.Heading, "Acceso institucional SGU");
|
||||
yield return new SmallLabelControl(
|
||||
ControlKeys.InformationLabel,
|
||||
"Usa tu clave institucional (DO, AL o AD + 6 dígitos) y contraseña.");
|
||||
|
||||
@@ -13,6 +13,7 @@ internal sealed class SguCredentialTile : CredentialTile2
|
||||
public SguCredentialTile(CredentialProviderBase credentialProvider)
|
||||
: base(credentialProvider)
|
||||
{
|
||||
GenericTileDisplayMode = GenericTileDisplayMode.DisplayAsDedicatedTile;
|
||||
}
|
||||
|
||||
public SguCredentialTile(CredentialProviderBase credentialProvider, CredentialProviderUser user)
|
||||
|
||||
Reference in New Issue
Block a user