Iprincipal & IIdentity problem

A

aneesh

HI All,
I ma new to .NET. I was a java programmer for the past 2 years, and now
shifted to .NET. My company (A product based company) is rewritng an existing
portal produt from java to .NET, using c# and asp.NET. I ma into the
authntication module of this particular development.

I have developed some classes called TeNPrincipal wich impliments the
IPrincipal and TeNIdentity which impliments the IIdentity, when I have a
certain other properties for our portal user specific thing.

Now after successfull authentication in the login.aspx.as codebehind, i set
the formsauthcookie and create a new instance of the TeNprincipal and
Tenidentoty and add this TeNIdentity to the TeNPrincipal.

Now the next thing i do is do something like this:
Context.User = newTeNPrincipal(Context.User.Identity, TeNSecurity.GetRoles());

and redirects tothe desktop.aspx

Now on the
desktop.aspx when i try

TeNPrincipal principal = (TeNPrincipal) HttpContext.curent.User;
I get error invalid cast:
And whne i chek the type of HttpContext.curent.User it shows GenericPrincipal)

I also tried TeNPrincipal principal = (TeNPrincipal) Context.User;

None worked. what could be wrong. for the timebeing, I made a wrapper class
which returns and sets the TeNPrinicipla for the
user(TeNSecurity.SetPrincipal(...) && TeNsecurity.GetPrincipal() will return
the Ten principal where I am setting it something like this:
HttpContext.Current.Session.Add("TENPRINCIPAL",principal);

Now I want that Context.User = Tenprincipal to work.

What could be wrong?

Regards
Aneesh A.V
 
B

Brock Allen

You must reset the HttpContent.User on each request into the application.
You should do this in global.asax (or in a HttpModule) in the Application_AuthenticateRequest
event.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top