22 March, 2014

URL Redirection / Vanity URL in IIS 7.5

We have a SharePoint site like www.sampleportal.com. Whenever user types the any word (eg. "employee”) after site name (www.sampleportal.com/employee) , it should redirect to another site www.employeeportal.com .

We can achieve this in two ways.
1.Using IIS URL Rewrite. [OR]
2.Adding URL redirect rule in Web.config file manually.

Method 1:Using IIS URL Rewrite

1) Open IIS Manager.
2) Under sites, select your site.
3) Under IIS section , you can see a module called “URL Rewrite”.
    If you are not able to see that module , you can download & install it from

4) Click on “Add Rule(s)” and select “Blank Rule”. Click on “OK”.

5) There will be four section which you need to fill.
a)      Name of the rule: You can provide a name for this rule Eg)”ReDirect To Employee Portal”.
b)      Pattern : In our case , it should match the word “employee”. So we can provide the pattern like “^employee$
c)      Conditions: Add the condition like base URL should be www.sampleportal.com .
 Set Condition Input: {HTTP_HOST} & Pattern “^www.sampleportal.com$
d)      Action: Set action type as “Redirect” & in Redirect URL provide the URL which you want to  redirect  “www.employeeportal.com”.


6) Click on “Apply” .

This method will add URL redirect rule in Web.config file automatically once we click on “Apply”.( We can add/edit/disable/remove the rule whenever needed via IIS URL Redirect)

Method 2: Adding URL redirect rule in Web.config file Manually.
(We need to be careful while doing changes to web.config file manually. Always take backup of web.config file before doing any modification’s)

Add the Below Rule  inside  <system.webServer> tag.
<rewrite>
     <rules>
             <rule name="ReDirect To Employee Portal">
                    <match url="“^employee$" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www.sampleportal.com$" />
                     </conditions>
                     <action type="Redirect" url="www.employeeportal.com" />
               </rule>
      </rules>
</rewrite>

Now it’s all set. Whenever user's hits the URL “www.sampleportal.com/employee” , it will redirect to www.employeeportal.com.

21 March, 2014

“Link to a Document” opens Read only documents

General note:
If you find a different solution, please report it as a comment to this post. Be sure to double-verify it: undo your solution and verify that the problem comes back, then redo it and verify that the problem goes away.

Today we are going to discuss a content type “Link to a Document”.

Basically these are summary points:-
1.     How to use and add this content type?
2.     Why this content open read only documents?

Let’s start with – How to use and add this content type?

By default only one content type is a part of any document library i.e. New Document – How to check this?

1)    Open your SharePoint document library
2)    Click on new
3)    You will see the content type named as “New Document”

Now I want another content type listed over there as “Link to a Document” – How to enable this?

a)     Open your SharePoint document library
b)    Top section ->Ribbon
c)     Library
d)    Library settings
e)     Advanced settings
f)      Enable this option – ‘Allow management of content types’
g)     Click OK
h)    You will again come back to the library settings page
i)       Scroll down to the same page
j)       There you go  - you will see a new section named as “content types”
k)     Click this options – “Add from existing site content types”
l)       You will see several content types under “Available site content types” gallery
m)  Scroll down to the list and select “Link to a document”
n)    Click Add
o)    Hit OK

By this way, we have successfully added the “Link to a document” content type (CT).

Now how to use this content type?
1.     Open your document library where we have enabled this content type
2.     Top Ribbon ->Library Tools
3.     New Document
4.     Select ‘Link to a document’
5.     You will see two fields Document Name and Document URL



6.     Enter the name as per your requirements and enter the document URL (How to get document URL? – Go to the document library where the document resides ->Right on that document for which you want to create a link ->Copy shortcut)

By this way – a link to document will be successfully created!

Now the times arrive to discuss issues w.r.t. this functionality.

Why the document which has been created by “Link to a document” content type opens only in “Read only” mode?

Not understanding the exact behavior – let’s try to reproduce it J

Let us create one hyperlink / link to a document in my document library – here is the screenshot


Click on it and you will get these options – Open, Save and Cancel.
Where is the edit option?

If you click on open ->document will open without any problems ->but if do any changes and try to save it then it will ask you to save locally

Is this I want? NO – I want that this document should be saved directly to SP and not locally!

Let’s try to understand this / check what is under the hood – How is this functionality working?

When we use the content type “Link to a document” then it will not be an office compatible component that we can use with word, excel or PowerPoint. It is simply an aspx page and it’s not possible to edit these pages in office version.

I have created a document share for this document library where I placed the “linked to document” content type.

Default visibility will show you that it’s an excel compatible as we have linked the excel document to it.

But if you create a network share for the same document library then it will reveal the real facts, like above.

From the screenshot, you will understand that it’s showing as aspx page and not an office document. ASPX page are not office compatible so it’s quite obvious it will give you the prompt of open, save and cancel.

I think the above explanation; most importantly the screenshot will clear the queries/doubts you have regarding this functionality.

Let me know in case of any, I would be more than happy to address your queries/issues, Thank you.

20 March, 2014

ERROR HRESULT E_FAIL while working on audit reports - Resolved

Error HRESULT E_FAIL while working on audit reports - Resolved

Problem description:
Facing an issue here in Audit Reports. The issue is when one site collection admin tries to run the Security Settings Audit report the report is getting generated successfully; however if another site collection admin tries to run the same report he gets an error. When checked in to the log files the error was "System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component. At System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal

Error message:
HRESULT E_FAIL has been returned from a call to a COM component. At System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal

Logs:
System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at Microsoft.Office.Server.OpenXml.Internal.ByteStream.Write(Byte[] rgb, Int32 offset, Int32 cb) at System.IO.BufferedStream.FlushWrite() at System.IO.BufferedStream.Flush() at System.IO.StreamWriter.Dispose(Boolean disposing) at System.IO.StreamWriter.Close() at System.Xml.XmlTextWriter.Close() at Microsoft.Office.RecordsManagement.Reporting.AuditReportGenerator.CloseDataPart() at Microsoft.Office.RecordsManagement.Reporting.AuditReportGenerator.Dispose() at Microsoft.Office.RecordsManagement.Reporting.ReportData.CloseCurrentReport() at Microsoft.Office.RecordsManagement.Reporting.ReportData.Dispose() at Microsoft.Office.RecordsManagement.Reporting.ReportBase.AggregateReports(Hashtable query, SPFolder folder, ReportNameGenerator reportNameGenerator) at Microsoft.Office.RecordsManagement.Reporting.ApplicationPages.CustomizeReport.OKBtn_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Troubleshooting steps:
1.   Working for few users so it’s not a global issue
2.   Working in other browser but not in IE
3.   There are no multiple domains for whom it’s not working
4.   No restrictions on user accounts via GPO
5.   No errors in the event logs
6.   Other SP functionality is working fine for those users for whom auditing is not working

Resolution:
1.   For whom it’s not working, let him logged in to the SharePoint site

2.   Open the SharePoint site

3.   IE -> Tools -> compatibility settings

4.   Check "Display all websites in compatibility view".

5.   Add your SharePoint site on the top ("add this website" section) if its empty (by default it takes but sometimes it’s not)

6.   Refresh it and check the results

If you have any queries/questions regarding the mentioned information then please let me know. I would be more than happy to help you as well as resolves your issues, Thank you.

If you find a different solution, please report it as a comment to this post. Be sure to double-verify it: undo your solution and verify that the problem comes back, then redo it and verify that the problem goes away.

Product applies to:
a)   SharePoint Server 2010
b)   SharePoint Foundation 2010
c)   SharePoint Server 2013
d)   SharePoint Foundation 2013

17 March, 2014

Health check page throwing 404 - File or directory not found - NLB configuration

Today I was working on configuring the network load balancer for our web front ends. Let me give you some details on this before I start explaining the issue – NLB configuration can be done in two ways as follows:
1.   Health check file (Recommended one) – running IIS required.
2.   TCP port based health check

I was using the recommended way i.e. first one (health check file). We have 5 web front ends, while doing the configuration; you need to place this file on all the 5 web front ends. Why? – Good question! – If one server goes down then the requests will automatically get routed to the next available server.

Once you have placed the file then you need to browse that file in browser, just to make sure that you are getting the reply like this – http://108.34.45.145/healthcheck.txt

Proper output should be there, if not then there is something wrong in configuration. I faced the same problem as I was getting the reply from one server only and remaining servers were throwing the following error message:

404 - File or directory not found.

HTTP Error 404.0 - Not Found the resource you are looking for has been removed, had its name changed, or is temporarily unavailable

If the one server is giving me a proper output then the question is why the other servers are not working! There should be some problem in configuration, let me clear – not from the NLB side but from the IIS side.

I checked the IIS of the server where it was working and compare it with the remaining ones but didn’t find any differences.

So I tried browsing the local host site which is by default there in IIS – You should get IIS construction page. I tried browsing this IIS default website from the servers where I am not getting the output and result was same i.e. default website giving me “webpage cannot be found”

Why the default websites giving me error message? – The reason is so simple as they are in stopped status J

The server where it’s working, I checked the status of the default websites and it was in started mode. So the bottom line is - Sometimes solutions are simple but took some time to figure it out.

Resolution for this issue:
If you are working on NLB configuration with respect to health check page then make sure the default web site in started status.

If you have any queries/questions regarding the above mentioned information then please let me know. I would be more than happy to help you as well as resolves your issues, Thank you.


If you find a different solution, please report it as a comment to this post. Be sure to double-verify it: undo your solution and verify that the problem comes back, then redo it and verify that the problem goes away.

Product applies to:
1.   SharePoint Server 2010
2.   SharePoint Foundation 2010
3.   SharePoint Server 2013
4.   SharePoint Foundation 2013
5.   SharePoint Server 2007

16 March, 2014

Sharepoint Administrator account Lost its control (Permissions) over a SiteCollection

Issue Description: User not able to perform the administrative task in a site collection(He is having full control over the site).Even Primary site collection administrator lost control over the site.



àWhen clicking on "Site Action", he is not able to see the full range of option like "create new site, Document library ..etc). He is able to see only few options as shown above.
à Administrator not able see option to add users under site permission.


àNobody could add new documents or edit documents, nearly every single Document or Library option is greyed out.

Resolution:

Method 1:

1.     Central Administration -> Site Collection Quotas and Locks.
2.     Select your site collection
3.     Change the Site Lock Information radio button from “Read-only” to “Not locked
4.     OK



Method 2: Use Stsadm command

stsadm -o setsitelock -url http://sitecollection -lock none

Root Cause: Usually While taking a sharepoint back up, site collection goes to read-only mode. Once it is completed it will returned to “Not Locked” mode.
Reason for this issue might be while taking back up got interrupted in middle and it left the site collection to read mode.