1

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!

2 Answers 2

1

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?

0

Membership.GetAllUsers()[USERNAME] working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.