May 07, 2019 03:43 PMfirstname.lastname@example.org|LINK
I have a piece of visual basic code which runs fine in my local machine and displays UPN on the screen.
Dim uID1 As String = UserPrincipal.Current.UserPrincipalName.ToString() // to retrieve UPN from Active Directory
However, when I publish the same code in IIS on the UAT server, the code throws an exception as per below
"Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrinicpal to type System.DirectoryServices.AccountManagement.UserPrincipal"
I am suspecting its due to the
Imports System.DirectoryServices.AccountManagement statement, which is not valid in
.NET 2.0 which is my UAT server .NET version.
Can help me on the workaround if any, on the below exception ? Looking forward to hear from you. Thanks.