Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 Windows 身份验证并获取用户信息,例如 Givenname、Surname 等。我UserPrincipal.Current在 IIS 中使用过,但出现异常,但 IIS express 看起来不错。
UserPrincipal.Current
我通过使用查找方法解决了:
var domain = new PrincipalContext(ContextType.Domain); var currentUser = UserPrincipal.FindByIdentity(domain, User.Identity.Name);