Showing posts with label FBA. Show all posts
Showing posts with label FBA. Show all posts

Saturday, August 6, 2011

Sharepoint 2010 Claims site - Add FBA users to Sharepoint group programmatically

Adding FBA users to Sharepoint group programmatically is simple. The hunch is the format "i:0#.f|fbamembershipprovider|" + username

In the format, 
i  - stands for Identity provider 
f  - stands for fba authentication
fbamembershipprovider  - is my providername

Here you go, a simple sample that servers the pupose.

SPSite sitename = new SPSite("SiteURL");
        SPWeb spWeb = sitename.OpenWeb();
        
        String strusername= "i:0#.f|fbamembershipprovider|" + UsernameTextbox.Text;
        spWeb.AllUsers.Add[strusername, EmailTextbox.Text, UsernameTextbox.Text, strusername];
       
         
            if (spUser != null)
            {
                SPGroup spGroup = spWeb.Groups["GROUP_NAME"];
            if (spGroup != null)
            spGroup.AddUser(spUser);
            }


Happy Coding :)

Forms Based Authentication in Sharepoint

How to configure FBA in MOSS 2007

To configure FBA in MOSS 2007, you basically need to extend your webapplication and add your membership & role provider.

Here you go  http://msdn.microsoft.com/en-us/library/bb975136.aspx

How to configure FBA in Sharepoint 2010

To configure FBA in SP 2010, you need not extend the current webapplication. You can create a brand new webapplication with claims enabled and can have FBA. Additionally you can have Windows Authentication too under claims.

Here you go http://technet.microsoft.com/en-us/library/ee806890.aspx