2

ASP.net MVC アプリケーションで Windows 認証を使用しています。Active Directory にクエリを実行して、現在のユーザーに基づいてユーザーの電子メール アドレスを取得したいと考えています。

IPrincipal principal = HttpContext.Current.User;

Active Directory を使用して電子メール アドレスを照会する方法はありますか?

4

1 に答える 1

-1
using (var context = new PrincipalContext(ContextType.Domain)) {
  using (var user = UserPrincipal.FindByIdentity(context, userName)) {
    if (user != null) {
       return user.EmailAddress;
    }
  }
}
于 2016-04-14T09:49:04.147 に答える