Configuring Forms Based Authentication (FBA) for SharePoint 2010


Create a new web application from Central Administration.

Select Authentication as Claims Based Authentication

Check Enable FBA checkbox and specify Membership provider name and role manager name as SqlMembers and SqlRoles.

Click on Ok to create the web application.

After successful creation of the web application create a site collection.

Navigate to C:\Windows\Microsoft.NET\Framework64\v2.0.50727 and run aspnew_regsql.exe tool there.

Follow the screen shots below to create a new database named MYFBADB.

After successful creation of the database add the following information(highlighted in yellow) to the web.config file of our FBA application

<membership
defaultProvider=i>

<providers>

<add
name=i
type=Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c />

<add
connectionStringName=SqlConn
applicationName=/
name=SqlMembers
type=System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
minRequiredPasswordLength=5
minRequiredNonalphanumericCharacters=0 />

</providers>
</membership>

<roleManager
defaultProvider=c
enabled=true
cacheRolesInCookie=false>
<providers>
<add
name=c
type=Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c />

<add
connectionStringName=SqlConn
applicationName=/
name=SqlRoles
type=System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a />

</providers>
</roleManager>
</SharePoint>
<connectionStrings>
<add
name=SqlConn
connectionString=server=crm2011;database=MYFBADB;Trusted_Connection=true />
</connectionStrings>
<system.web>

Next open the web.config of the Central admin site and add the same information added above

<roleManager
enabled=true
defaultProvider=AspNetWindowsTokenRoleProvider>
         <providers>
             <add
connectionStringName=SqlConn
                 applicationName=/
                 name=SqlRoles
                 type=System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a/>
         </providers>
     </roleManager>

         <providers>
             <add
connectionStringName=SqlConn
                 applicationName=/
                 name=SqlMembers
                 type=System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a />
         </providers>     </membership>

</SharePoint>
    <connectionStrings>
        <add
name=SqlConn
connectionString=server=crm2011;database= MYFBADB;Trusted_Connection=true />

    </connectionStrings>    
<system.web>

Lastly add the following configuration information in the web.config file of the SecurityTokenServiceApplication (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken)

    </system.net>
    <connectionStrings>
        <add
name=SqlConn
connectionString=server=crm2011;database= MYFBADB;Trusted_Connection=true />
    </connectionStrings>    <system.web>
        <membership
defaultProvider=SqlMembers>
            <providers>
                <add
connectionStringName=SqlConn
applicationName=/
name=SqlMembers
type=System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a />
            </providers>
        </membership>
        <roleManager
enabled=true
defaultProvider=SqlRoles>
            <providers>
                <add
connectionStringName=SqlConn
applicationName=/
name=SqlRoles
type=System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a/>
            </providers>
        </roleManager>
    </system.web>

That’s it.

Adding User to SharePoint Group through a custom ASP.NET web service.


I had a requirement to create a web service which would be used to add user to a SharePoint group. The code for it

[WebMethod]
public  string AddSharePointUser(string username,string password, string email){
string statusInfo = “”;
try
{
s
tring SharePointUrl = ConfigurationManager.AppSettings[“SharePointUrl”].ToString();
string SharePointGroup = ConfigurationManager.AppSettings[“SharePointGroup”].ToString();

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSiteCollection = new
SPSite(SharePointUrl))
{
oSiteCollection.AllowUnsafeUpdates = true;
using (SPWeb oWebsite = oSiteCollection.OpenWeb())
{
oWebsite.AllowUnsafeUpdates = true;
SPUser spUser = oWebsite.EnsureUser(username);

SPGroup spGroup = oWebsite.SiteGroups[SharePointGroup];

spGroup.AddUser(spUser);
oWebsite.AllowUnsafeUpdates = false;

}

oSiteCollection.AllowUnsafeUpdates = false;

}});

statusInfo = “User Created Successfully”;

}
else
{
statusInfo = “User Already Exists”;

}}
catch (Exception ex)
{
statusInfo = ex.Message;

}
return statusInfo;

}

To run the web service successfully, we need to set the identity of application pool of the web service to SharePoint Administrator account.

Hope it helps.

Using Change Password ASP.NET control in SharePoint 2010 FBA.


Create a new SharePoint 2010 Empty Project in visual studio 2010.

Right click the project à Add New Itemà Select “Application Page”.

Add the ChangePassword control inside PlaceHolderMain content place holder

<asp:Content ID=”Main” ContentPlaceHolderID=”PlaceHolderMain” runat=”server”>

<asp:ChangePassword
id=”myChangePassword”
newpasswordregularexpressionerrormessage=”Error: Your password must be at least 5 characters long, and contain at least one number and one special character.” runat=”server” CancelDestinationPageUrl=”~/pages/default.aspx” OnContinueButtonClick=”ContinueClickHandler” MembershipProvider=”SqlMembers”  OnChangingPassword=”ChangingPassword” OnChangedPassword=”ChangedPassword”></asp:ChangePassword></asp:Content>

Put the following code for OnChangingPassword and OnChangedPassword Event handler in the code behind. 

 // the username would be in the following format
 // 0#.f|sqlmembers|nishantr
 // so we need to get only the username part
 // otherwise it wont work properly
protected void ChangingPassword(object sender, EventArgs e)
{
System.Web.UI.WebControls.ChangePassword chngPassword = (System.Web.UI.WebControls.ChangePassword)sender;
chngPassword.UserName = chngPassword.UserName.Substring(chngPassword.UserName.LastIndexOf("|") + 1);
}

// add reference to Microsoft.SharePoint.IdentityModel dll
protected void ChangedPassword(object sender, EventArgs e)
{
System.Web.UI.WebControls.ChangePassword chngPassword = (System.Web.UI.WebControls.ChangePassword)sender;
FormsAuthentication.SignOut();
Microsoft.SharePoint.IdentityModel.SPClaimsUtility.AuthenticateFormsUser(new Uri(SPContext.Current.Web.Url), chngPassword.UserName, chngPassword.NewPassword);
}


Check this really helpful pack

http://sharepoint2010fba.codeplex.com/

Hope it helps.

Add reference to Microsoft.SharePoint.IdentityModel.dll


Had trouble finding the above assembly to add reference to it. It wasn’t there in the 14 hive. The location where we can find it is

C:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.IdentityModel\

Bye.

SPUpgradeException Exception message: An error has occurred on the server.http://go.microsoft.com/fwlink?LinkID=96177


Hi I got the error while trying to open the SharePoint Site after applying the MOSS SP2 update to it.

This post was helpful in resolving that error

http://social.technet.microsoft.com/forums/en-US/sharepointadmin/thread/4cce44de-4b5a-4dcb-a369-be65654ff80e/

  • Nachrichten dieses Autors suchen

    Hi Guys

    I had the same problem. and i fixed it by going here
    http://www.microsoft.com/downloads/details.aspx?familyid=A49472F9-93E…

    download the file that matches your OS. ie x32 or x64
    If you try to run the file it will tell you the patch is already installed.
    but run the file with “/extract” extrace the file to someware and run
    “dw20w.msp”
    Let it do its thing. It takes a while……Then presto. well as least for
    me.

    Let me know how you guys go with it.

    Hope it helps!

Customizing NewForm.aspx and EditForm.aspx pages for Lists.


Recently, I was assigned a task to customize the NewForm.aspx and EditForm.aspx for a particular list. The list was part of a site definition generated using SharePoint Solution Generator.

The reason we wanted to customize the page was because we wanted one custom field to be added (drop down list) that would display all the content types in that site.

You can find the sample project and related files over here

Link:- https://nishantrana.me/wp-content/uploads/2010/06/sharepointproject.doc

Please rename the file from SharePointProject.doc to SharePointProject.zip after downloading it.

Bye..