Get UPN or email for logged in user in a .NET web application

后端 未结 3 454
误落风尘
误落风尘 2020-12-10 01:16

I\'m not a .NET developer, and I have a feeling this would be trivial for someone who is:

I have a C# web application that makes user of the user credentials of the

3条回答
  •  情歌与酒
    2020-12-10 01:49

    Meanwhile (.NET 3.5) this is a one-liner:

    System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress
    

    for the email, or

    System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName
    

    for the UPN.

提交回复
热议问题