我目前使用IdentityServer3和AspNetIdentity。现在我想将身份验证扩展到活动目录。为此,我想在登录屏幕上创建一个复选框,用户可以在其中决定是否要对活动目录或本地数据库进行身份验证:
现在我的问题是:
如果选中了Windows身份验证的复选框,我在自定义用户服务中需要这些信息。然后我可以编写以下代码:
public async override Task AuthenticateLocalAsync(LocalAuthenticationContext context)
{
// check if the option for windows authentication is set
// Yes: Authenticate over active directory: UserPrincipal.FindByIdentity(principalContext, username)
// No: Authenticate over local database
}
这是解决我的要求的好方法还是有更好的解决方案?我想为用户设计尽可能简单。
感谢您的帮助!!