Login Related Problem

S

Samuel Shulman

Hi all

1. When allowing a user to change their username the system still has the
original username in the 'User.Identity.Name'
and this property is Read Only

2. Related question how can I set the user as logged without using the
'FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, False)' method


Thank you,
Samuel
 
G

Guest

Question 1 - make sure you set authenticate type to 'forms' or 'none' in the
web.config file, then attach CustomPrinciple to current request.

sloppy quick way: store in session

middle ground: Use the global.asax OnAuthenticate method to authenticate
the user. Create a CustomPrincipal object and attach it to the current
thread, then the IsAuthenticated will be true.

example: (in the global.asax OnAuthenticate method)

-- authenticate user against db, file, etc..... then...

CustomIdentitiy id = new CustomIdentity("myName");
string[] roles = { "role1", "role2" };
CustomPrincipal p = new CustomPrincipal(id, roles);
HttpContext.Curent.User = p;

better way: create a class that implements IHttpModule and do same as above
in the OnAuthenticate method.
 

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

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top