Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'System.Web.Securi

Discussion in 'ASP .Net Security' started by kroyce@ups.edu, May 1, 2007.

  1. Guest

    I completed the How To on using Forms Authentication with Active
    Directory and am receiving an error when casting Current.User to
    FormsIdentity object. I can't find my error nor can I find anything
    through Google, MSDN or KB on the issue. This leads me to believe it
    is my issue and I need some help if at all possible. The error
    message I receive is:

    Unable to cast object of type
    'System.Security.Principal.GenericIdentity' to type

    My c# code looks like the following and I am using ASP.Net 2.0:
    lblName.Text = "Hello " + Context.User.Identity.Name + ".";
    lblAuthType.Text = "You were authenticated using " +
    Context.User.Identity.AuthenticationType + ".";
    FormsIdentity id =
    FormsAuthenticationTicket ticket = id.Ticket;
    lblCookieUserName.Text = ticket.Name;
    lblCookieData.Text = ticket.UserData;

    Context.User.Identity.Name works great as does

    The offending piece of code is:
    FormsIdentity id =

    Any help or insight that you can provide would be very much
    , May 1, 2007
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.