|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Update Profile of Created Userall 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. -- Morgan Web Developer Portland, Oregon 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 (waw***@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. 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 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 (waw***@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. 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. Walter Wang [MSFT] wrote: Show quote > 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 (waw***@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. |
|||||||||||||||||||||||