How to use Membership Request Functionality?

I've replied to the duplicate question you posted here:

http://sharepoint2010fba.codeplex.com/discussions/261249

i have added  custom fields(Phone and Contract Number) to membership request webpart, user name, password are  stored in the database,  but custom field values like  phone and contract  values are not stored in the data base  please help me  with small example 

hi,

  Have  you added  custom fields to  membership request webpart and  store that values in database??  please  help  if  you have done  urgent

 

When I've added extra fields, i've stored them in SharePoint on the user profile.  If you'd like to do that, here's a couple of links that should lead you in the right direction:

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/7f40ff43-68b6-4ee0-bc69-496cda99c46d/

http://www.zimmergren.net/archive/2008/06/25/sharepoints-hidden-user-list-user-information-list.aspx

Thks for the quick reply, i was able to solve the problem using  following way, i used this in oncreated event

 

MembershipUser

 

newUser = Membership

.GetAllUsers()[request.UserName];

 

Guid newUserId = (Guid

)newUser.ProviderUserKey;

 

String

FirstName = request.PhoneNumber;

 

String

LastName = request.CbsAccountNumber;

 

string connectionString = ConfigurationManager.ConnectionStrings["SQLConnectionString"

].ConnectionString;

 

string insertSql = "INSERT INTO Profile(UserId,FirstName, LastName) VALUES(@UserId, @FirstName, @LastName)"

;

 

using (SqlConnection myConnection = new SqlConnection

(connectionString))

{

myConnection.Open();

 

SqlCommand myCommand = new SqlCommand

(insertSql, myConnection);

myCommand.Parameters.AddWithValue(

"@UserId"

, newUserId);

myCommand.Parameters.AddWithValue(

"@FirstName"

, FirstName);

myCommand.Parameters.AddWithValue(

"@LastName"

, LastName);

myCommand.ExecuteNonQuery();

myConnection.Close();

}

HI,

  Iam using Password recovery webpart its working fine , how  can  i  use  same  webpart  if  user  forgets  his  UserName/Email  and remembers only password. Urgent can we do in sharepoint 2010??

That seems strange. By looking up a user by password, you run the risk of multiple users having the same password - so you could end up giving a user access to an account he shouldn't have access to.  You also make your site easily accessible to hackers - as they can just start entering common passwords until they find a user with that password. So I wouldn't recommend this. If you really want to do it, there is no method for doing it via the SqlMembershipProvider, so you would have to extend it and write your own.

hi,

  Thanks for the quick reply, i  will tell my  client the same  and  sure  they will agree.

hi,

This is regarding membership Registration,

Before creating user i have to chek in database for  contract  number whether  it is valid contract number  or not  where  should i  write this code,oncreating  or  oncreated ??

OnCreating - because you're still able to cancel the creation if the contract number is not valid.  

Since (I assume) you'll have to add another field with the contract number, you might just want to add a custom validator to it and do the validation there.

hi,

  yes  you are  correct,  and thanks for the suggestion.

 

How  i should add captcha to the passwordrecoverywebpart in FBA?  very  urgent

Look at "AddHipControls" of "MembershipRequestControl.cs".  That's essentially the code that adds it to the Membership Request webpart.  So i'd just take that and work at adding it to "PasswordRecoveryWebPart.cs"

hi,

 

  iam using createuserwizrad control in visualwebpart and adding user the user is added in the database but not appearing in the Form auth, its unable to find the user? please help me  out  very urgent..should i set any attributes in the control my settings are as follows

<asp:CreateUserWizard runat="server" ID="CreateUserWizard1" OnCreatedUser

="CreateUserWizard1_CreatedUser"

 

 

BorderColor="#616D7E" BorderStyle="Solid" BorderWidth="2px"

 

 

 

 

RequireEmail="True" DisableCreatedUser="false" OnCreatingUser="CreateUserWizard1_CreatingUser" CompleteSuccessText="Your Account has been Created" CreateUserButtonText="Submit" CreateUserButtonStyle-Font-Bold="true" ContinueDestinationPageUrl="~/_layouts/CBS.MyCBSOutdoor.Application/customlogin.aspx" >

>

The CreateUserWizard will only add the user to the membership database.  If you want the user to appear in SharePoint you have to add the user to a group. Why don't you just use the Membership Request Control, which does all this for you?

when i add using your membership request webpart, the user is added perfectly and seen in Form auth.

for above case and  for your membership request webpart, for both iam using same web.config files.

i have some customizations, so iam using create user wizrad control, the concept like  i create a sub site add that user to the sub site as owner of the site? to do so what should do plase help me out

Look at the MembershipRequest.cs code and copy the portion for adding the user to a SharePoint group into your code. Modify as needed.  That should do it!

iam using

SPGroup ownersGroup = web1.Groups["TestFBA Owners" 

];

ownersGroup.AddUser(UserName, UserName, UserName,"New User"

);

 

 

// ownersGroup.AddUser(spUser);

ownersGroup.Update();

 is this the correct way.

Here's the line of code that does it for the membership request web part:

web.SiteGroups[request.DefaultGroup].AddUser(Utils.EncodeUsername(request.UserName.ToLower(), web.Site), request.UserEmail, request.FirstName + " " + request.LastName, "Self Registration");
The one thing you're missing is encoding the username into the claims format with Utils.EncodeUsername.