If somebody like the post and its helpful in your work then, add comments.

Friday, July 23, 2010

SharePoint 2010 : Custom Membership and Role providers

 

Hi all,

Now these day I was busy with some SharePoint 2010 project. One of my project I have to configure Form Based authentication for the site. In this configuration we didn't use the default Asp.Net providers for authentication.

“ASP.NET membership is designed to enable you to easily use a number of different membership providers for your ASP.NET applications. You can use the supplied membership providers that are included with the .NET Framework, or you can implement your own providers.”

So I have create or we can implemented the custom provider class with custom SQL database and tables. We have inherited the asp.net abstract classes “MembershipProvider” and “RoleProvider”  in our custom classes. The project is class library project for creating DLL, e have to used for installing in GAC.

This Membership Provider class have following following structure:

Variables

        private int newPasswordLength = 8;
        private string connectionString;
        private string applicationName;
        private bool enablePasswordReset;
        private bool enablePasswordRetrieval;
        private bool requiresQuestionAndAnswer;
        private bool requiresUniqueEmail;
        private int maxInvalidPasswordAttempts;  private int passwordAttemptWindow;
        private MembershipPasswordFormat passwordFormat;
        private int minRequiredNonAlphanumericCharacters;
        private int minRequiredPasswordLength;
        private string passwordStrengthRegularExpression;
        private MachineKeySection machineKey; //for encryption

Properties

VISIOITPro000

Method which I have implemented:

VISIOITPro002

And the methods which I have not Implemented:)

VISIOITPro001

Their are some other helper methods also there like encryption for password. Similarly I have implemented role providers. Well you can get both the classes from here.

Some more configuration you have to make for the SharePoint 2010 FBA like STS, Central Admin and your port 80(primary web app) application.  I have manually manipulated all web.config files of application and they are working.

Enjoy :)

2 comments:

  1. hi,

    I'm try to use custom membership provider on sharepoint 2010 application.But I have a big problem.

    I have no problems when use the passwordFormat "clear" but i change it to "Hashed", I get an this error. "This provider instance has already been initialized."

    What could be the reason for this.

    can you help me pls. thanks

    ReplyDelete
  2. It's possible to create custom provider with mysql database for sharepoint FBA ?

    ReplyDelete