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:


        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



Method which I have implemented:


And the methods which I have not Implemented:)


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 :)