0

I am using the below,

string fmail = UserPrincipal.Current.EmailAddress();

This is returning the logged in user's email when tried from local machine but when hosted in IIS server i am getting the below error,

Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'.

Please help me with a resolution . I am using asp.net.

  • maybe https://stackoverflow.com/questions/11014406/unable-to-cast-object-of-type-in-system-directoryservices-accountmanagement-grou – TheGeneral Sep 16 '21 at 07:37
  • I have already gone through that , i did not find solution for getting email address from there – Arun Ezhil Sep 16 '21 at 09:12
  • You can also try the code in this link: [https://stackoverflow.com/questions/38352816/ad-email-address-is-inaccessible-in-asp-net-website-on-server-only](https://stackoverflow.com/questions/38352816/ad-email-address-is-inaccessible-in-asp-net-website-on-server-only). – samwu Sep 17 '21 at 09:43

0 Answers0