Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I followed this http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/ to setup a sharepoint site with forms based authentication, and it worked fine.

now i want to built a Webpart to create users? so i written below code.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Security;
using System.Configuration.Provider;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using CKS.FormsBasedAuthentication;
namespace GenerationSurvey.CreateUser
{
  public partial class CreateUserUserControl : UserControl
  {
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Create_btn_Click(object sender, EventArgs e)
    {
      object providerUserKey = System.Guid.NewGuid();

      MembershipProvider p = Membership.Providers["MyMemberShipProvider"];
      string password = Membership.GeneratePassword(7, 1);
      MembershipCreateStatus strOut;

      p.CreateUser(tbUsername.Text.Trim(), password, tbEmail.Text.Trim(), "", "", true,providerUserKey, out strOut);    

      MembershipRequest request = new MembershipRequest();
      request.FirstName = tbFname.Text.Trim();
      request.LastName = tbLname.Text.Trim();
      request.Password = password;
      request.UserName = tbUsername.Text.Trim();
      request.UserEmail = tbEmail.Text.Trim();

      MembershipRequest.ApproveMembership(request, SPContext.Current.Web);

      //it throws exception at below line "The method or operation is not implemented "

      MembershipUser user = Membership.GetUser(tbUsername.Text.Trim()); 

      bool status = user.ChangePassword(user.GetPassword(), tbPword.Text.Trim());
    }
  }
}

but it throws exception at this line MembershipUser user = Membership.GetUser(tbUsername.Text.Trim()); and exception says "The method or operation is not implemented"

i dont know , where the issue is. is it issue with how i setup environment? or something wrong in code?

Please share your thoughts.

Thanks in Advance!

share|improve this question

2 Answers 2

For a start, I think you may need to elevate permissions in your code, so that it can run under the SharePoint System Account permissions (which you should have set up in the FBA user database to have permission to write to).

According to this the GetUser method shouldn't throw a NotImplementedException... Odd.

Have you tried p.GetUser instead?

share|improve this answer

Membership.GetAllUsers()[USERNAME] working fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.