【发布时间】:2015-01-09 00:57:29
【问题描述】:
我正在使用 WebAPI 并使用 Katana 托管它。我现在正在编写一些用于身份验证和授权的中间件。我必须对 SSL 使用基本身份验证,因为请求可能来自各种平台。 OAuth 目前也不是一个选项。中间件需要获取基本身份验证提供的用户名和密码,并验证用户是本地 Windows 组的成员。
现在我正试图弄清楚如何创建一个 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();
我正在努力寻找一种使用用户名和密码来验证该成员是否属于特定组的好方法。做这个的最好方式是什么?提前感谢您的帮助。
【问题讨论】: