Thursday, February 3, 2011

Coping DLL from the Global Assembly Cache

You Can Easily copy any .dll which is installed in GAC using windows. If you browse to assembly folder placed in c:\windows you will have only the option to uninstall. Rather you browse to GAC_MSIL folder under c:\windows\assembly you can see the installed assembly folders. Each folder has a subfolder under it. In sub folder you can find the DLL what you need. There is no need of using the shfusion.dll to copy the DLL’s.

Steps are as follows:

1.       Browse to c:\windows\assembly\ GAC_MSIL
2.       Each assemblies has a folder, with each version being a subfolder under that.
3.       In the subfolder is the DLL that you can copy to a different folder of you choosing.


Wednesday, February 2, 2011

Control Anonymous User from Accessing Application Pages

I came across a requirement where the SharePoint site should be enabled for the anonymous users in the meantime, they should be restricted to view from the application pages. So first my choice was ViewLockDownFeature, shipped with SharePoint 2007 STSADM. I thought I saved the time by just enabling the feature would solve me the problem. Yes it solved me the problem but it spawned me another problem where the feature blocks the anonymous users navigate to the blog entries, since the blog entries are accessing the Lists directly and get the page contents.

Sample Url of blog

../myblog/Lists/Categories/Category.aspx?CategoryId=2&Name=Category 2

Workaround 1:

Setting the policy at web.config level.

<configuration>

<location path="_layouts/viewlsts.aspx ">

<system.web>

<authorization>

<deny users="*"/>

</authorization>

</system.web>

</location>

</configuration>

For further information follow up here.

The problem in the above method is, if you want to block all the application pages and still wants the blog accessible to anonymous users, then you have to specify all the application page url.

Workaround 2:

Tweaking with Delegate control

SharePoint is a pool to play with delegate controls, where the winner is supposed to get a chunk of development time compared to other optional method.

Normally SharePoint delegate controls resides in Master page and Page layout as well as in Application Pages. First I delve into the delegate controls for the custom navigation control. This is the second time, where I observed that all the application pages are having the delegate control. So overriding the delegate control in the following manner will help you to implement your own policy to ranging from different user groups to different site, page and to url level.

public class AnonyousePolicy:UnsecuredLayoutsPageBase

{

protected override void OnLoad(EventArgs e)

{

if (System.Web.HttpContext.Current.Request.Url.PathAndQuery.IndexOf("_layouts/RedirectionModule/") > 0)

{

//Do Nothing as Anonymous users need to get that redirection available

}

else if (System.Web.HttpContext.Current.Request.Url.PathAndQuery.IndexOf("_layouts/", StringComparison.InvariantCultureIgnoreCase) > 0)

{

if (SPContext.Current.Web.CurrentUser == null)

{

// Anonymous user, prevent access

SPUtility.TransferToErrorPage("Anonymous users have no access to this page");

}

}

}

}

Conclusion : I feel the first method is a simple way to block the anonymous users, provided the accessibility is not restricted upon the user group and less number of application pages.

Second method is handy method is more flexible than the first method I hope !

Expect your feedback.

Sunday, December 12, 2010

WCF/ADO.NET Data Services - Could not load type 'System.Data.Services.Providers.IDataServiceUpdateProvider'

For the SharePoint 2010 users, you might wonder the announcement of Microsoft for the support of RESTFul services is giving error when you try to access the /_vti_bin/listdata.svc.

Error : Could not load type 'System.Data.Services.Providers.IDataServiceUpdateProvider' from assembly 'System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Work-around :
For Windows Vista and Windows 2008 - http://www.microsoft.com/downloads/details.aspx?familyid=4B710B89-8576-46CF-A4BF-331A9306D555&displaylang=en

For Windows 7 and Windows 2008 R2 - http://www.microsoft.com/downloads/details.aspx?familyid=79d7f6f8-d6e9-4b8c-8640-17f89452148e&displaylang=en

P.S : Don't forget to reset the iis. Otherwise you will get the error recurrently.

Tuesday, November 30, 2010

SP2010 URL Field Type Enhancement

I've observed a nice feature offered by Microsoft SharePoint team when I was trying to migrate the contents from one server to another. In Sharepoint 2007, you will not get an automatic conversion of existing URL when you are migrating list items among the servers (Header of URL). But in SharePoint 2010 it does.

Observation:

Server 1
I've pointed some of the assets by giving the absolute URL path
I want all those list items to be migrated to another server called Server 2

I've used SPContent Deployment Wizard to do the job.
Amazingly all the URL headers of the absolute path is converted in adherence to Server 2

You may ask whether the above tool does the job for you.
The answer is NO. Because I've checked the latest release note of that tool to see whether it supports that kind of fancy conversion.

My next step is to dig on the same stuff to see whether it accepts relevant URL header when I migrate the list items from one server to another server's sub-sitecollection

I'll come up with the latest note on that.

Stay tuned...

Monday, November 22, 2010

MCTS Sharepoint Developer Certification (70-573)


Recently I have sit for the Sharepoint Developer Examination, which is anticipated unlike Administration Examination, a tough exam by my colleagues, though none of them have not tried at least once :) . Everyone pushed me towards the dead-end for the trial, and I also well prepared on the core API of Sharepoint. Since I have been actively working on Sharepoint for last one year, most of the API is covered through out my tasks, which enabled me to go for a dry run on the new features introduced in Sharepoint 2010 API such as SPListCollection.TryGetList etc.

These are the steps I've focused once I've decided to embark on the Sharepoint bed.
First, I've done some POCs based on the weight of skills to be tested.
Microsoft Preparation Guide

Lets say, TimerJob implementation is included in the preparation list, I've written a simple TimerJob and deployed as Farm Administrator and note down if any issues encountered.
But at the exam, required us to be familiar with the sandboxed solution deployment as well, where as we deploy everything as Farm Administrator. So for the audience, I'm encouraging all you to go through the dual deployment steps and get hold of the stuffs as its a new feature introduced in SharePoint 2010; I meant the SandBoxed solution.

Atlast, outline given by Microsoft is analysed detailed and provided reference on the following blog, which was a worth guide for me.
Guide with References

If any specific clarification neede on the exams, just post me your questions.

Friday, November 19, 2010

Pagination for joint DVWP

As you might see, in sharepoint 2007 and in par with in sharepoint 2010 follow the same method on pagination for the joint list DVWP. If you add a single list, to DVWP and add pagination value, it normally works as expected. But once you link the existing datasource with another list, it automatically removes the pagination from the rendering part, still it keeps the xsl tags in the back-end. So how to enable the out of the box pagination.
Lets say "Category" List and "SubCategory" Lists are there. You are showing Sub Categories for the given Category. But all happens through the webpart. No addition of content type in page layout (Client requirement as they want to use the same layout for different purpose). If you link Category and SubCategory, pagination disappears. so you can't limit the number of SubCategories showing in webpart. In order to resolve that issue...
Obviously you can't enable the pagination by switching on and off, where as you have to write the xsl for the <xsl:template name="dvt_1.commandfooter"> template.
The parameters for the commandfooter template will be the same as default

<xsl:call-template name="dvt_1.commandfooter">
  <xsl:with-param name="FirstRow" select="$FirstRow" />
  <xsl:with-param name="LastRow" select="$LastRow" />
  <xsl:with-param name="RowLimit" select="$RowLimit" />
  <xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
  <xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" />
</xsl:call-template>

and the template will be implemented like this

<xsl:template name="dvt_1.commandfooter">
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:param name="RowLimit" />
<xsl:param name="dvt_RowCount" />
<xsl:param name="RealLastRow" />
<xsl:variable name="preNumber" select="$FirstRow - $RowLimit" />
<xsl:variable name="nextNumber" select="$FirstRow + $RowLimit" />
<table><tbody><tr>
<xsl:if test="$FirstRow > 1">

</xsl:if><td>
<a href="/test1.aspx?PageLimit=$preNumber">Pre</a>
</td>

<xsl:if test="$nextNumber <= $dvt_RowCount">
</xsl:if><td>
<a href="/test1.aspx?PageLimit=$nextNumber">Next</a>
</td>
</tr>
</tbody></table>
</ xsl:template>

the parameter binding will be added with one more data as follows

<parameterbinding name="PageLimit" location="QueryString(PLimit)" defaultvalue="1" />

This is to limit the number of rows on the second list of joint view.
Assign the variables as follows

<xsl:variable name="FirstRow" select="$PageLimit" />
<xsl:variable name="LastRow" select="$FirstRow + $RowLimit" />

Call the body as follows

<xsl:call-template name="dvt_1.body">
  <xsl:with-param name="RowLimit" select="$RowLimit" />
  <xsl:with-param name="Rows" select="$Rows" />
  <xsl:with-param name="FirstRow" select="$FirstRow" />
  <xsl:with-param name="LastRow" select="$FirstRow + $RowLimit - 1" />
</xsl:call-template>

Now you are done with your pagination


P.S: This is my first blog post. Add your comments. :)