Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Security / December 2005

Tip: Looking for answers? Try searching our database.

ASP.NET 2.0 Profile/Membership/Forms Authentication - Manual Login

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
beaudetious - 29 Dec 2005 07:09 GMT
I'm working on an ASP.NET 2.0 web app using C# and SQL Server 2000.  I've
created a multi-step user profile page using the wizard web control and when
the user clicks on the finish button on the final screen I have code in the
click event on the server that does the following:

- Creates a new user using Membership.CreateUser()
- Adds this new user to a default role using Roles.AddUserToRole()
- Inserts the other form fields into various tables in the DB
- Sends a confirmation email

What I'd like to do now is to add some of the fields (i.e. First Name and
Last Name) to the Profile class (which is already setup properly via my
web.Config file).  I'm doing the following:

 Profile.FirstName = txtFirstName.Text;
 Profile.LastName = txtLastName.Text;

However, I'm getting a Provider.ProviderException stating "This property
cannot be set for anonymous users.".  Checking the NewUserInfo properties it
appears this newly created user is logged in and shouldn't be anonymous.

So, given the brief overview of what I've done and how I've accomplished it,
how do I now authenticate this newly created user behind the scenes so that I
can associate this profile data with this user?  When all is said and done, I
do not mind if the user is pre-authenticated and pre-authorized after
following all of my registration steps.   Who'd want to fill out one more
form just to login at this point?  :)

beaudetious
Dominick Baier [DevelopMentor] - 29 Dec 2005 08:17 GMT
Hi,

well - the user is not authenticated yet - he will be after the next roundtrip
after the Authenticate_Request event.

One option would be to set these values in the anonymous profile and handle
the Profile_Migrate event to migrate the anon profile to the authenticated
profile on the next roundtrip

Another thing i haven't tried is: Profile looks for Context.User.Identity.Name
and IsAuthenticated - i am not sure at which stage he does that - maybe you
can fake that
by creating a GenericIdentity / Principal and set this to Context.User before
calling the Profile API.

tell us if that worked for you.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

> I'm working on an ASP.NET 2.0 web app using C# and SQL Server 2000.
> I've created a multi-step user profile page using the wizard web
[quoted text clipped - 26 lines]
>
> beaudetious
beaudetious - 29 Dec 2005 15:34 GMT
Here's what I did to get this to work.

ProfileCommon PC = (ProfileCommon) ProfileCommon.Create(
NewUserInfo.UserName, true );
PC.FirstName = this.txtFirstName.Text.Trim();
PC.LastName = this.txtLastName.Text.Trim();
PC.Save();

I got this from Scott Guthrie's blog:
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

> Hi,
>
[quoted text clipped - 47 lines]
> >
> > beaudetious
beaudetious - 29 Dec 2005 15:35 GMT
Dominick,

I did check to see if the Context.User.Identity IsAuthenticated and it came
back as false at this point in my code.

> Hi,
>
[quoted text clipped - 47 lines]
> >
> > beaudetious

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.