Thursday, November 27, 2014

Manage Web Application Policy using SharePoint PowerShell Script

Remove a existing Web Application Policy using SharePoint PowerShell Script

# Get the Web Application Object
$webappobj = Get-SPWebApplication [Web Application URL]

# Return the Web Application policies and find the index of the policy which you would like to delete

# Put the index value and delete the policy


# Verify the policies again if it is deleted successfully

Add a new Web Application Policy using SharePoint PowerShell Script

# Get the Web Application Object
$webappobj = Get-SPWebApplication [Web Application URL]

# Create a policy role object with permission level like FullRead, FullControl etc.
$fullReadPolicyRole = [Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead
$policyRole = $webappobj.PolicyRoles.GetSpecialRole($fullReadPolicyRole)

# Add the new web app policy with account name and account description
$policy = $webappobj.Policies.Add("TECHMM\SSWAIN", "Samarendra Swain")

# Bind the policy role to the new web  app policy


Tuesday, November 18, 2014

Configure Forms Based Authentication(FBA) in SharePoint 2013

SharePoint is mostly used for intranet portals in the organizations. People in the organization have their own LAN ID and Password(which setup in Active Directory) through which they access the SharePoint portals. By default SharePoint site uses windows authentication to authenticate users, that means any users from Active Directory in the organization can access to SharePoint sites if they grant the permission by Site Collection Administrator.

Now if organization would like to provide access to External Business Users where they do not have any account in Active Directory, then you can configure Forms Based Authentication(FBA) with SQL Membership Provider to provide them access in the SharePoint Portals.

Few years back, I had implemented in MOSS 2007. Now I have configured the same in SharePoint 2013. It's almost same.

Let's go through below steps to configure FBA with SQLMembership Provider for a SharePoint portal. 
  • At first you need to create an new database which will store the information of External Users in a ASP.Net membership database. Open the directory in any SharePoint Server (C:\Windows\Microsoft.NET\Framework64\v4.0.30319) in the SharePoint server.
  • Run aspnet_regsql.exe file and Click Next.
  • Select 'Configure SQL Sever for application services' and click Next.
  • Provide the SQL Server name where you would like to create this database. Then provide the Database Name and click Next.
  • Verify the SQL Server name, new Database Name and click Next.
  • Now the new database needs to created in the SQL Server. Click Finish to close the window.
  • Now open SQL management Studio, then connect to the SQL server to verify the New database and the tables.
  • Expand the New Database -> Expand Security -> Right click on Users to Create a New User -> Add the application pool account of web application as log-in name and select all the _Full Access schemas from Owned Schemas section. See the below screenshot for reference.

Now membership database has been configured to store External Users information. So we need to register external users which will stored in this database.

At this point there is no external user created yet in the above ASP.Net membership database. Codeplex provides solutions for registering users, changing passwords and password recovery in the membership database. Please download the SharePoint 2013 FBA Pack and deploy the WSP file into the web application where your site collection resides.  

SharePoint 2013 FBA Pack link:

Step 1: Download the package and find out the WSP file(visigo.sharepoint.formsbasedauthentication.wsp).
Step 2: Add the solution file using below PS command.

Add-SPSolution -LiteralPath e:\downloads\visigo.sharepoint.formsbasedauthentication.wsp

Step 3: Go to Central Administration Site -> System Settings -> Solutions Management -> Select the solution file and deploy to the web application where your site collection resides.

Once solution is deployed you can able to see it in Solution management as below.

Once the solution gets deployed, Site Collection Administrator needs to activate the Forms Based Authentication Management feature in Site Collection features page. 

Then Site Collection Admin can see the below links in the site collection settings page to manage users.
Note: These features will be only available to Site Collection Administrator to manage them.

Now Site Collection Administrator can register external users,to do that click FBA User Management -> Create User -> Provide the detailed information with User ID, Password.

Once the user got created successfully, Site collection admin can see the user details as below.

You can also verify the same in the membership database as below that one row has been added to aspnet_Users table.

Now go to Central Administration site -> Manage Web Applications -> select an web application where your site collection resides -> Click on Authentication Provider -> Click Default Zone -> Select "FBA_SQL_MembershipProvider" for ASP.NET Membership provider name and write "FBA_SQL_RoleProvider" for ASP.NET Role manager name. See below screenshot for reference.

  • Now you need to add the SQL Connection String, People Picker Wildcards entryASP.Net Membership Provider and ASP.Net Role Manager entries to below 3 web config files.Please follow the below screenshots with entries of each part to web.config files.
  1. Web Application Web.Config file(in WFE servers)
  2. Central Admin Web App Web.Config file(in CA hosted server)
  3. Security Token Service Web.Config file (located in 15 hive folder\WebServices\SecurityToken\web.config) - in in both WFE servers and Application Servers
  •  SQL Connection String Entry:
    <add name="fbaSQLConnection" connectionString="server=WIN-5KDVOHD7F4P\SHAREPOINT;database=FBA_ExternalUsers;Trusted_Connection=true" />

Screenshot for reference:

  • People Picker Wildcards Entry:
      <clear />
      <add key="FBA_SQL_MembershipProvider" value="%" />
  • ASP.Net Membership Provider Entry:
    <add connectionStringName="fbaSQLConnection" applicationName="/" name="FBA_SQL_MembershipProvider
                 type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.3600.0, 
                 Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

  • ASP.Net Role Manager Entry:
 <add connectionStringName="fbaSQLConnection" applicationName="/" name="FBA_SQL_RoleProvider
             type="System.Web.Security.SqlRoleProvider, System.Web,Version=2.0.3600.0, 
             Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Screenshot for reference:

Now Administrator can inform to External Business User and provide her the User ID and Password to login to the SharePoint Portal. Later on external user can change her password.

External User can browse the portal where she will find two option and she needs select Forms Authentication to login to portal.

Select Forms Authentication and input the user id and password.

Now you can able to see the portal with External User logged in credentials.

If you see the my settings of the logged in user, you find the account information as below. You can also find this user in the People Picker Control while providing permission to any SharePoint list/library/group.

That's all :) 

Tuesday, November 15, 2011

Avoid checked out issue while drag and drop multiple documents using Explorer View

When multiple files are dragged and dropped into SharePoint using explorer view, all files are shown as checked out in SharePoint even though check-in/check-out are not required on document library.

Solution: Enable content type at document library level and make the Title column as optional for the content type document. Then try to upload the multiple documents using explorer view. It will work fine as expected.

Wednesday, November 9, 2011

Enable Web folders in SharePoint Explorer View

Some of the below points you should aware if web folder is not working properly in your SharePoint site.
*       When you try to access an Explorer View page on Windows Server 2003, you will sometimes receive the following error: “Explorer View requires Internet Explorer 5.0 or greater and Web Folders.”
This is typically caused by the fact that Windows Server 2003 does not include Web Folders (FPRPC) technology and, by default, the Web Client Service is disabled.
You can resolve this in one of two ways:
1. Install Microsoft Office 2003 or FrontPage on the server. Office 2003 and FrontPage install Web Folders components which will then allow you to access the Explorer View using FPRPC.
2. Enable the Web Client Service on the server. (We have tested in our production which did not work out)
*       If anybody out there has been building demo machines on Windows Server 2008 or Windows Server 2003 you will have run into this issue at some point. Explorer View does not work on document libraries, nor can you map a network drive to a SharePoint site.
Solution:  The server platforms effectively don't like web folder views until you install the fix KB907306. That fixes works for both Windows 2003 and 2008.
Now you can happily map a SharePoint site to your network places and use the Windows Explorer to browse the SharePoint sites.
*       It does not seem to be the problem with an internet explorer. When you attempt to way in an Explorer View page on Windows 7 then you must receive the following error: “Explorer View requires Internet Explorer 5.0 or greater and Web Folders.” Actually this issue comes when your operating system does not include the Web Folders (FPRPC) technology and this service is disabled by default on client machine. To solve this problem, you just need to install the FrontPage on the server then you may try doing the same thing.
Reference Link:

Thursday, September 8, 2011

Tips: Unexpected issue in the out-of-box functionality of SharePoint site

One interesting issue !
Suppose just before yesterday you checked that your SharePoint site was working fine, but today you start getting unexpected issue in the out-of-box functionality of SharePoint site( like displaying All Items data, Deleting List Item/Library or Creating View etc.), Then you might thought that without any changes how can the issue arise. Yes you are right, but do you regularly verify the content database size of the site collection. Yes, those unexpected error comes whenever the Content DB has no free space to use. Now it's your task to increase the Content DB size.
I got below error while displaying All Items data for a library.
<---Render Method ----!>
Then I verify the event Viewer where I got the error that TempDB is expecting some space to do the SharePoint transactions(whether displaying data, creating or deleting items etc).
-Samarendra swain

Friday, April 8, 2011

SharePoint 2010 : Display new form, edit form and display form of a list/Library in full page instead of in dialog box.

Go through the below steps to achive the same.
  • Open the List/Library.
  • Go to settings of the list/library.
  • Go to advanced settings.
  • Select 'No' in Dialogs section like below screen shot.

Now check the New form, Edit form and Display form for that list/library. You will able to see the forms in full page instead of dialog, like below screen shot.

Enjoy !

Thursday, February 17, 2011

Remove ’s while exporting excel file using RenderControl method of GridView or DataGrid or DataList control.

Example: ‘Employee’s home’ was coming like ‘Employee’s home’ while exporting to excel file where it should come like the original one.

Code Snippet:
Function  ExportToExcel( GridView  gv)
            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Test.xls"));
            HttpContext.Current.Response.ContentType = "application/ms-excel";

            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);


 // add the below marked line to fix that issue
            HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("Windows-1252");

            HttpContext.Current.Response.Write(strHeading + oStringWriter.ToString());