Files
SGU-CredentialProvider/src/SGU.CredentialProvider/SguCredentialProvider.cs
T

56 lines
2.2 KiB
C#

using System.Collections.Generic;
using System.Runtime.InteropServices;
using Lithnet.CredentialProvider;
namespace SGU.CredentialProvider;
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SGU.CredentialProvider")]
[Guid(ProviderClassId)]
public sealed class SguCredentialProvider : CredentialProviderBase
{
public const string ProviderClassId = "D789CFD8-5AD4-489F-9B83-7EB5D9D09335";
public override IEnumerable<ControlBase> GetControls(UsageScenario cpus)
{
yield return new CredentialProviderLabelControl(
ControlKeys.ProviderLabel,
"Acceso Institucional");
yield return new CredentialProviderLogoControl(
ControlKeys.ProviderLogo,
"Acceso Institucional",
ProviderTileIcon.Create());
yield return new LargeLabelControl(ControlKeys.Heading, "Iniciar sesión")
{
// Isolate the CPFT_LARGE_TEXT heading from the compact provider tile
// for the selected-layout variant. LogonUI still owns the typography.
State = FieldState.DisplayInSelectedTile
};
yield return new SmallLabelControl(
ControlKeys.InformationLabel,
"Escribe tu usuario institucional o de dominio y contraseña.");
yield return new TextboxControl(ControlKeys.UserName, "Usuario");
SecurePasswordTextboxControl password = new(ControlKeys.Password, "Contraseña");
yield return password;
yield return new SubmitButtonControl(ControlKeys.Submit, "Iniciar sesión", password);
}
public override bool IsUsageScenarioSupported(UsageScenario cpus, CredUIWinFlags dwFlags) =>
cpus is UsageScenario.Logon or UsageScenario.UnlockWorkstation or UsageScenario.CredUI;
public override bool ShouldIncludeUserTile(CredentialProviderUser user) => false;
public override bool ShouldIncludeGenericTile() => true;
public override CredentialTile CreateGenericTile()
{
SguCredentialTile tile = new(this);
DefaultTile = tile;
return tile;
}
public override CredentialTile2 CreateUserTile(CredentialProviderUser user) =>
new SguCredentialTile(this, user);
}