我正在使用WebAPI并将其托管在Katana中。我现在正在编写一些中间件,用于身份验证和授权。由于请求可能来自各种平台,因此我必须使用带SSL的基本身份验证。目前OAuth不是一个选项。中间件需要接收基本身份验证提供的用户名和密码,并验证用户是否为本地Windows组的成员。
现在我正在尝试找出如何创建WindowsPrincipal。如果我知道如何从用户名和密码创建WindowsPrincipal,那么我就知道如何完成其余部分。以下是我目前拥有的代码:
现在我正在尝试找出如何创建WindowsPrincipal。如果我知道如何从用户名和密码创建WindowsPrincipal,那么我就知道如何完成其余部分。以下是我目前拥有的代码:
//TODO
WindowsPrincipal userPrincipal = null; //This is where I need to take the username and password and create a WindowsPrincipal
Thread.CurrentPrincipal = userPrincipal;
AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
PrincipalPermission permission = new PrincipalPermission(null, "Local Group Name");
permission.Demand();
我正在努力寻找一种好的方法,使用用户名和密码验证成员是否属于特定组。最好的方式是什么?提前感谢您的帮助。