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 / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Update Profile of Created User

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Morgan - 28 Jun 2006 23:17 GMT
I've created my own version of the CreateUserWizard control that gathers up
all the information I need when a user requests an account.  Once all the
data is gathered and validated, the FinishButtonClick property calls a method
that does the following:

1. Creates the user account:
Membership.CreateUser(myName, myPwd, myName, myQue, myAns, true, out
createStatus);

(I'm using the email address (myName) as the username, which is why it shows
up twice)

2. I then want to update the newly created user's profile with the
information that was entered:

        Profile.UserInfo.UserEmail = UserName.Text;
        Profile.UserInfo.FirstName = FirstName.Text;
        Profile.UserInfo.MiddleInitial = MI.Text;

..etc.

I do not want these profiles created for anonymous users, so my web.config
file looks like this:

   <anonymousIdentification enabled="false" />
     <properties>
       <group name="UserInfo">
         <add name="FirstName" type="System.String" allowAnonymous="false" />
         <add name="MiddleInitial" type="System.String"
allowAnonymous="false" />
         <add name="LastName" type="System.String" allowAnonymous="false" />

..etc.
       </group>
     </properties>

I have tried several methods to ensure that the newly created user is logged
in, by using the Membership.ValidateUser(), the
FormsAuthentications.AuthorizeUser(), and none of them have worked.  However
the MembershipUser object returned by the CreateUser method shows that that
user is currently OnLine.  I always end up with the following error message
the moment I try to call the SetPropertyValue of the first profile property:

"This property cannot be set for anonymous users."

Note that I do not want the user to be able to log in yet until their
account has been approved, so once the profile info is created I would have
to log them out and set their account to Inactive.

Thanks for any and all help.

Signature

Morgan
Web Developer
Portland, Oregon

Walter Wang [MSFT] - 29 Jun 2006 12:52 GMT
Hi,

Thank you for your post.

I think you can create and save the profile manually after you created the
user:

   ProfileCommon p = (ProfileCommon) ProfileCommon.Create(username, true);
   p.UserInfo.UserEmail = UserName.Text;
   ...
   
You can find more info here:

#How to add a Login, Roles and Profile system to an ASP.NET 2.0 app in only
24 lines of code
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Morgan - 29 Jun 2006 19:46 GMT
Thanks, that seems to be the answer!  One other question tho, how do I then
retrieve the profile of a user who is not logged in?  I noticed that there's
a ProfileCommon.GetProfile(string username).  Is it that easy?

Morgan
Web Developer
Portland, Oregon
Walter Wang [MSFT] - 30 Jun 2006 02:30 GMT
Hi Morgan,

Thank you for your update.

Yes you can use the GetProfile() function to get the profile of a user.
This generated function actually has following code:

   public virtual ProfileCommon GetProfile(string username) {
       return ((ProfileCommon)(ProfileBase.Create(username)));
   }
   
ProfileBase.Create() is used to create an instance of a profile for the
specified user name. It's also used when migrating anonymous users:

<%@ Application Language="VB" %>
<script runat="server">

   Sub Profile_MigrateAnonymous(ByVal s As Object, _
     ByVal e As ProfileMigrateEventArgs)
       Dim anonProfile As ProfileCommon = _
         Profile.GetProfile(e.AnonymousId)
       Profile.FavoriteColor = anonProfile.FavoriteColor
   End Sub
     
</script>

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
gwing02@gmail.com - 30 Jul 2006 00:03 GMT
Hi:

I am running into a problem with the ProfileCommon.  I have an
administration page where the profile of any user may be updated
through a ProfileCommon instance.

However, if the administrator is logged in and tries to edit his own
information, it won't "stick."  It will work if I add a condition
stating that if the user being editted is the user who is making the
edits, the Profile object should be used instead of creating a
ProfileCommon object.

Is this normal behavior and a normal workaround?

Thanks.

> Hi Morgan,
>
[quoted text clipped - 34 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.

Rate this thread:







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.