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

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

  1. kroyce

    kroyce 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
    kroyce, May 1, 2007
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.