Showing posts with label sharepoint. Show all posts
Showing posts with label sharepoint. Show all posts

Thursday, March 14, 2013

Deploy SharePoint solutions at web application level

SharePoint solution packages by default get installed to "Globally" scope when you don't have any resources which are web application scoped. It is not a logical decision to deploy in web application scope when I have Assemblies to GAC, Application pages to Layouts folder etc. If there are any resources which are targeted at web application scope like deploying assemblies at Application bin directory, safe control entry etc then the solution deployment will force us to deploy at web application level.

Some times you will have assemblies to GAC, not a web part project and don't have any resources which are scoped against web application. At this juncture, you may need to deploy the solution at web application scope for various reasons like

  • Security  - To hide features part of the solution from showing off in other web applications.
  • Shared Environment - Other applications running in the Farm and they don't to get impacted of your WSP
  • Isolation - Having a global scoped WSP will recycle all app pools during deployment
This can be achieved by adding a safe control entry to the solution package and solution deployment script will be satisfied by this. If it is MOSS 2007 then its matter of Manifest.xml modification. But SharePoint 2010 is powered with Visual Studio 2010 tools for SharePoint, if we make any modification to Manifest.xml then the Package designer will ignore its support to the developer.

The solution would be, open your package designer, scroll down and find the Advanced Tab, click on "Add" button to add additional assemblies.



Select "Add assembly from project output", input the namespace and full assembly name for the safe controls.

Save these settings and hit on Ok button,one more setting to update. Click on the project in solution explorer and press F4 to open the properties window, exclude the assembly from being copied to solution package.Because we already added the assembly in "Additional Assembly" section.


Package and deploy the solution at web application level scope.

Thursday, February 14, 2013

Portable mail server on desktop for SharePoint

I used to run an SMTP server which comes along with IIS 6.0 whenever I need to test an outgoing emails from a custom SharePoint solution. After a long time I hate running a server process just to receive a bunch of emails relayed within my development machine and also due to compliance, network administrators may block the SMTP server in a desktop.

Here comes a nifty tool from Codeplex called Papercut for all our problems. Ok, how to resolve the SMTP puzzle ?


  1. Download Papercut from CodePlex, unzip the zip package (Note: there is no msi package or a setup.exe, so you are not violating software compliance too) and keep it in a handy location
  2. Find your machine IP first by using ipconfig and make a note.
  3. Map your IP to SharePoint’s outgoing mail settings in SharePoint Central Administration console.



Open PaperCut.exe -> click on “Options” -> Map your machine IP here. Keep it open and running, do not close.


Now test all your email functionalities and you should be seeing all emails in the left pane with time stamp.

Watch all your mails are being forwarded to Papercut.exe.


Thursday, April 26, 2012

SharePoint performance tuning

There are various factors which comes in to scene when we enter the performance tuning for SharePoint, lets see the major players

HTTP Compression
  • It provides on the fly compression on files when served from the web server to the browser. 
  • It can be configured on file type extension(htm,js,css etc).
  • This setting applies on web application level and in disabled state by default.
  • Compression puts pressure on Server's processor but gives an instant boost to the application
  • HTTP sniffing tools like Microsoft Fiddler or HTTP Watch can be used to verify the traffic.
Browser Caching
  • Modern browsers come with private caching ability up to 1 GB.
  • It can improve performance for sites which contain more static pages, can be tweaked in IIS HTTP response headers(cache-control: max-age=3600, post-check”)
  • Easy to configure and implement 
BLOB Caching
  • BLOB Caching stores all of its content on disk , it is also configured based on the file types
  • Configurable in web.config the file types, max size(10 GB default) and enable/disable switch.
  • It works at the web application level, this option is disabled by default.
 Object Caching
  • Object caching caches site navigation structure, published pages and resources, draft pages etc.
  • It is enabled by default at site collection level, the Farm admin might see it a bit daunting task to manage across all site collections :(.
  • It also stores cached objects on disk and shares the space with BLOB cache.
  • Need to be bit careful before increasing or decreasing the allocation of this Cache control, any unplanned configuration can deteriorate the existing performance
Browser Connections
  • Internet Explorer 7 and earlier versions limit the number of concurrent file download as two at a time. IE 8 relaxed this limitation to six.
  • When you work on faster connections, this browser setting might be a bottleneck for users in seamless performance.
  • Microsoft provides a fix for this limitation  http://support.microsoft.com/kb/282402.
  • This restriction was imposed by IETF RFC 2068 Page 45 and the explanation goes like this
 "Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD maintain AT MOST 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion of the Internet or other networks."
Other options
  • Now a days Proxy servers & Load balancers are supporting static content caching, verify the feasibility on this.
  • ISAPI filter from Aptimize can reduce significant performance bottlenecks.

Friday, December 23, 2011

SharePoint List items bulk delete

Recently while working on a production case, we needed to delete around 2000 list items in a single shot. My idea was to use the data sheet view ActiveX control to do the bulk delete. But in production case where the server runs on 64 bit and clients run on 32 bit, there was problem invoking the ActiveX control and shared  the following snippet to do a batch delete.

private static void deleteAllListItems(SPSite site, SPList list)
{
StringBuilder sbDelete = new StringBuilder();
sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");
string command = "<Method><SetList Scope=\"Request\">" + list.ID + "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar     Name=\"Cmd\">Delete</SetVar></Method>";
foreach (SPListItem item in list.Items)
{
Console.WriteLine(item.Title);
sbDelete.Append(string.Format(command, item.ID.ToString()));
}
sbDelete.Append("
");
Console.WriteLine("now deleting");
site.RootWeb.ProcessBatchData(sbDelete.ToString());
}

This snippet deletes that huge list much faster than traditional object model way.

Friday, August 19, 2011

Designing a video Streaming Portal - Part 1

The core idea is to build a video streaming portal which leverages SharePoint assets and also ensure that the solution is not burning our pockets. This solution will be totally based  on Free software or the software which the cost was already included with operating system license and with bare minimal code.

Software involved:

Implementation

Windows Media Streaming Services
          Deploy and enable Windows Media Streaming services in a Windows Server 2008. This service is capable of streaming video files in MMS or HTTP protocol, depends upon the client which is requesting. If the request is raised from Windows Media player then the server switches to MMS protocol, for any other clients it'll be HTTP protocol. This is called as Protocol roll-over.
          Windows Media Streaming services support WMV,WMA,asx and wsx file formats.Among this asx and wsx are play list format. So convert your videos to WMV videos.If your video library is full of FLV and flash files then its worth taking a look IIS Media Services.
            Map the video folder to appropriate publishing points, this will give you a unique end point to each and every media file. If you've enabled HTTP protocol then this will create a web application in IIS default port 80. It is recommended to expose HTTP protocol along with MMS protocol because MMS is compatible only with Media player client.If you are planning to build your own streaming client then your ideal end point would be HTTP.

SharePoint Foundation 2010
           Create a custom list and add columns Title, description, endpoint and comments. If you want to capture more metadata about the media asset, pile up here. Populate the list with the list of publishing points which are exposed by Windows media streaming services. It gives a chance of automation but for the sake of simplicity we are populating it manually.
           Develop a web part which lists all entries in this list on a left pane and Windows Media player ActiveX control on right pane. Whenever the user selects a video on left pane, modify the url property of ActiveX control and start playing. Let the ActiveX control do all heavy lifting for us.

SharePoint Search Server Express 2010
             SharePoint Search server express is good enough for small organization to start with and to get a flavor of Enterprise Search experience without any additional cost. Although it comes with the limitation on items which gets crawled it is a best fit for this solution.
              Deploy SSX2010 and configure the search and managed meta data(if required).Initiate an crawl on the content and get it indexed. Create a search center and test the search results. Now edit the search results web part to include "endpoint" managed meta data in query columns list. Modify the search results XSLT to render a small thumbnail of Media player plug-in which allows the user to play the videos right there in the search results
 
 Configuration , setting up the servers, pros and cons will be part of next post...

Tuesday, June 7, 2011

Querying calendar list by meeting workspace Url

Calendar list doesn't support querying the list by a workspace url making it a daunting task for finding a recurrence meeting workspace URL in Calendar list. U2U CAML editor and SharePoint views are unable to break this nut.

The trick to accomplish is to pass the relative URL for the CAML segment for querying. Following code snippet helps better understanding.

//removing the Server hostname and protocol, eg:- stripping http://Foo from http://Foo/meetingsite
string hostServer = meetingWeb.Site.Protocol + "//" + meetingWeb.Site.HostName +":" + meetingWeb.Site.Port;
searchUrl = searchUrl.Replace(hostServer, string.Empty);
SPQuery qry = new SPQuery();
qry.Query = @"<Where><Eq><FieldRef Name='Workspace' />
 <Value Type='URL'>" + SPEncode.UrlEncodeAsUrl(searchUrl) + "</Value>" +"</Eq></Where>";
qry.ViewFields = @"<FieldRef Name='Title' />
              <FieldRef Name='Location' />
              <FieldRef Name='EventDate' />
              <FieldRef Name='EndDate' />
              <FieldRef Name='fAllDayEvent' />
              <FieldRef Name='fRecurrence' />";
DataTable tbl= list.GetItems(qry); 

Sunday, June 5, 2011

CrossListQueryInfo and CrossListQueryCache gotchas

CrossListQueryInfo class which comes with the Microsoft Publishing infrastructure makes use of object caching techniques to query the requested data from the cache instead from the database. Remember to use this facility only if your code runs against a MOSS server and not on a WSS server. As this makes use of  object cache stored in WFE servers, it avoids to database input/output and network latency between the WFE's and database server.

Although it uses SPSiteDataQuery internally,the very first request using CrossListQueryCache takes more time than SPSiteDataQuery. Practically it includes the time for querying, caching and returning the values. But subsequent queries fetch results in a flash and no where comparable with SPSiteDataQuery.

Interesting fact is that this CrossListQueryCache and QueryInfo will not work in a Console line tool, it badly depends on the context. If you are really trying this interesting query technique in a web part, whenever you implement any change in your webpart and trying to debug. Apart from doing the IISReset/App pool recycle, don't forget to flush the object cache

A sample CrossListQueryCache
public DataTable GetDataTableUsingCrosslistQuery(SPSite site)
{
CrossListQueryInfo clquery = new CrossListQueryInfo();
clquery.RowLimit = 100;
clquery.WebUrl = site.ServerRelativeUrl;
clquery.UseCache = true ;
clquery.Lists = "";
clquery.Webs = "";
//clquery.Query = "";
clquery.Query = "569";
clquery.ViewFields = "";
CrossListQueryCache cache = new CrossListQueryCache(clquery);
DataTable results = cache.GetSiteData(site);
return results; 
}

Tuesday, May 10, 2011

Multiple NT authentication prompts in MOSS 2007 Server

In our team, people usually build their own development machines from the scratch and recently faced this multiple authentication prompt issue while accessing central administration right after the PSConfig wizard execution.

We tried all the browser tricks
  • switching off the IE Enhanced security configuration
  • Adding the site to IE's Local intranet zone
  • Checking the IE cookie storage setting and Authentication settings
Nothing worked, still there were multiple  authentication prompts and Fiddler showing many HTTP 401 requests. Even without providing the username and password, by pressing the ESC key continuously we were able to reach the Central administration home page. But none of the Ok/Cancel button worked as expected and leaving the Central admin console useless.

Finally Manimaran,  found a  Microsoft's KB article 95271, which clearly says you guys might be trying to install IIS 6.0 on top of a Windows Server 2003 SP2.

The machine was patched with Windows Server 2003 SP2 and we installed IIS 6.0 using an RTM disc which apparently reverted some libraries to its older version especially asp.dll. Replacing only this library didn't workout and I don't want to re-install OS Service Pack 2 again.

Workaround without re-installing Win 2003 SP2:
  • Keep Win 2003 SP1 and SP2 installation media handy in a drive.
  • Extract I386 content of these service packs using an archive tool, mine is 7zip
  • Uninstall SharePoint server and delete the content databases in database.
  • Remove the machines application server role and Uninstall IIS 6.0
  • Add Application server role , Install IIS 6.0 
  • Whenever the installer prompts for files to install point to the folder where you extracted SP2
  • In case if you don't find the files in SP2 folder, drill down in SP1 folder else in RTM disc.
Thats it now start installing SharePoint now.

Wednesday, April 20, 2011

Continuous Integration and remote deployment for SharePoint

This is a short guide of setting up a Continuous integration server and integrating with different plugins to analyse the code quality. At the end of the pipeline, we'll deploy to a remote staging server. The core idea is to build the solution on top of open source stack rather than  proprietary solutions like TFS.

Setting up Continuous Integration server:

  • Although there are tons of CI tools available in the market,as CruiseControl.Net looked for great for integrating various tools we picked up CruiseControl for our implementation.
  • Install CruiseControl.Net on a designated build server
  • CC.NET supports various source control blocks CVS,Subversion,VSS,SourceGear, StarTeam etc.
  • Download a command line client for the source control repository, for Subversion download this CollabNet Subversion command line client
  • Upon successful installation, browse to the folder C:\Program Files\CruiseControl.NET and open ccnet.config file in a text editor.
  • Add the project level detail

<project name=" testProject">
<workingDirectory>C:\develop\project1WorkingDir </workingDirectory>
</project>
  • Add source control block, which contains the SVN repository end point and credentials required to access these resources.
<sourcecontrol type="svn">
<trunkUrl>svn://Foo/trunk</trunkUrl>
<Working Directory>C:\develop\project1WorkingDir </workingDirectory>
<username>ccnet </username>
<password> ccnet </password>
</sourcecontrol>
  • Now we've added a Subversion URL with required credentials to access 
  • Let's add a Trigger block to tell the integration server at what frequency it should get latest and do a build. set the frequency as 360 seconds.
<triggers>
<intervalTrigger name="Subversion" seconds="360" buildCondition="ForceBuild" />
</triggers>
  • Add a Task block for building the solution, CC.net supports various build automation engines such as MSBuild, VSDevenv,NAnt  etc. We'll configure for MSBuild.
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<WorkingDirectory>C:\develop\project1WorkingDir</workingDirectory>
<projectFile>Sampleprojects.sln</projectFile >
<executable>
</tasks>
  • Alternatively if you want to use Visual studio to build the solution, following fragment will be helpful
<devenv>      
<solutionfile>C:development\Foo.sln</solutionfile>
        <configuration>Debug</configuration>
        <buildtype>Clean</buildtype>
        <executable>C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe</executable>        <buildTimeoutSeconds>360</buildTimeoutSeconds>
      </devenv>
  •  Add an Executable Task in this section after the build task for integrating other third party analysis tools like Microsoft FxCop for static code analysis, SPDisposeCheck tool for memory leak test, Microsoft StyleCop etc.
</exec>
<exec executable="C:\Program Files\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe">      <buildArgs>C:Foo\bin</buildArgs>
</exec>
  • Above Exec snippet requires all binaries to be stored in a single folder to run SPDisposeCheck, this can be done by adding a post build command in CS Project files.
  • Integrate Unit test case execution tools and code coverage tools like MSTest and NUnit test.
Package and move to staging server
  • Add a Exec task tag for WSP Builder
<exec executable="C:\Program Files\WSPTools\WSPBuilderExtensions\WSPBuilder.exe"><baseDirectory>C:\Foo\solutions</baseDirectory>      <buildTimeoutSeconds>360</buildTimeoutSeconds></exec>
  • Add a task which executes a xcopy command to move all these wsp packages to a staging server
<exec executable="C:\WINDOWS\system32\xcopy.exe">
<buildArgs>C:\Foo\Solutions\Output.WSP\*.wsp \\md-stagingSvr\share</buildArgs></exec>
Remote deployment with Sysinternal's PSExec

  • Add  another exec task to invoke PSExec tool to do the remote deployment
  • Alternatively if you have Windows Powershell in these machines you can make use of power shell to do the remote deployment.
<exec executable="C:\SysinternalsSuite\psexec.exe">
<buildArgs>\\md-stagingSvr-u "md-stagingSvr\aravind" -p 123$ "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o addsolution -filename c:\share\output.wsp</buildArgs></exec>


Tuesday, March 15, 2011

List does not exist error


While adding a new list view web part to a homepage , stuck with the following exception.
List does not exist The page you selected contains a list that does not exist. It may have been deleted by another user.
After some fiddling, found Web.Id for a LVWP is required to resolve this issue. After providing the WebId for the ListViewWebPart, web part adds to the page perfectly.

ListViewWebPart lvp = new ListViewWebPart();
lvp.ListName = Web.Lists["Tasks"].ID.ToString("B").ToUpper()  ;
lvp.ZoneID = "Center";
lvp.Title = "Tasks List";
lvp.WebId = Web.ID;  
SPFile homePage = Web.GetFile("default.aspx");
SPLimitedWebPartManager webmngr = homePage.GetLimitedWebPartManager (PersonalizationScope. Shared);
webmngr.AddWebPart(lvp, "Center", 3);
webmngr.SaveChanges(lvp);

Happy SharePointing :)

Monday, February 7, 2011

SharePoint 2010 Approval workflow, a marvel

Way back our team built a multi stage approval workflow with serial and parallel flow options for MOSS 2007. Recently stumbled upon the SharePoint 2010 approval workflow which eventually showcases all these functionalities right out of the box. This is one of the huge improvement in SharePoint 2010

Lets see what are the configurable parameters it allows us to configure

Approvers
Accepts multiple users who are in the capacity of approving the content ,seperated by semicolons

Order:
Determines in which order the execution goes whether serial or parallel, technically in which order the tasks created to the Approvers

Flow of a Serial workflow


Flow of a Parallel workflow

Expand Groups
If checked and groups entered in approvers section will be expanded and tasks will be created for individual users else only a single task will be created for the whole group. Any user from the group can approve or reject

Request
A comment text which will be sent to the approver via email and approval screen also

Due Date for all Tasks
Final date on which all approvals should be completed

Duration per task
Amount of time for each task is due, works along with Duration Units

Duration Units
You can choose days,months or years in this drop down, works along with Duration per task

CC
Want to keep an additional person in approval loop, this is the place to go

End on First Rejection
Any approver rejects the document, workflow gets stopped and document rejected

End on Document Change
Some author changes the original document while the approval in progress, now the whole workflow gets terminated if the original is modified.

Enable Content Approval
Changes the content approval status of the library based on workflow approval

Sunday, January 16, 2011

SQL server at xxx has an unsupported version 10.0.2531.0, SharePoint PSConfig error

While I was preparing a bonsai SharePoint 2010 web farm with Sql Server 2008 Enterprise database in my Dell Studio 1555. As I did numerous standalone SharePoint 2010 deployment for development activity on Windows Server 2008/R2/Win 7 with Sql Server 2008 express + SP1, I used to have the pre-requisites handy in my hard disk to build multiple virtual hard disks.
After building and networked the domain controller and the enterprise database server, executed the SharePoint 2010 installer and ran the PSConfig wizard on designated app server image. While connecting to the database server, wizard throws an error
---------------------------
SharePoint Products Configuration Wizard
---------------------------
SQL server at windb\dbsvr2010 has an unsupported version 10.0.2531.0. Please refer to "http://go.microsoft.com/fwlink/?LinkId=165761" for information on the minimum required SQL Server versions and how to download them.
---------------------------
OK   
---------------------------
I never expected this behavior ,went back to my standalone SharePoint installation and verified the database server. It says 10.0.2531.0 and running happily.
Went back to MSDN Hardware and Software requirement, there's a different standard for Sql Server 2008 Express(standalone) and Sql Server 2008 Enterprise(Farm installation). 
If you are gonna install Sql Server Express 2008 as your data store you are good enough to go with only Sql Server SP 1 (10.0.2531.0) but if you are preparing a web farm and proceeding for Non-Express database then you should also install the Cumulative update 2(10.0.2714) or CU5 (Installing CU3 or CU4 is not recommended)
Now the PSConfig wizard is happy and configures my web farm successfully.

Friday, January 7, 2011

Expose SharePoint 2010 Central Administration out of the job server

We tried to access the central administration of a Test server(Windows 2008 R2, IIS 7.5) from a client machine by adding proper host entries and providing the right port number and we were able to access the central administration. But soon we realized that the hyperlinks end up in a ASP.NET authorization error.

After tweaking the following authorization settings IIS 7.5 admin console, we were able to expose the links

Open inetmgr and select ASP.NET Authorization


Expand the central administration node and Select the _admin node and you can see a "Deny" rule, remove the deny rule and add a "Allow" rule



Repeat the same for _vti_adm node


Do an IISReset and good to go, 

Even after this some buttons from the Ribbon were disable for e.g;,Create application, Extend application 

Switching off the User account control solves the issue, start -> search for UAC and do the following change

Instructions provided above relaxes the security on SharePoint Server and shouldn't be applied on test,stage or production servers.

 

Tuesday, January 4, 2011

Porting Sharepoint 2007 document library STP to SharePoint 2010

Recently read a post from Tom Belgium which speaks about porting SharePoint 2007 list templates to SharePoint 2010 and it worked just by replacing the product version and and repackage with makecab utility.

I faced a scenario to port a document library STP template including some documents.SharePoint packages the documents of the document library and manifest.xml as a single package.

Following are the steps to modify the STP file.
Rename the STP File to a CAB file and have a look at the contents
Create a new folder in c: drive say c:\Templates\, drag and drop all the contents from the cab file
Edit the Product version tag in Manifest.xml and save the file
Open a command prompt, navigate to the folder where we copied contents from CAB file and take the list of files in a txt/ddf file. Store this file within C:\Templates folder

Prepare the DDF file with the list of obtained file names, don't forget to give the cabinet file name in DDF file
Download the sample DDF file here


Execute Makecab utility to generate the CAB archive, you will see a C:\templates\Package folder and within that folder the STP will be available

This is the new STP file which will work in SharePoint 2010 edition.

Friday, December 24, 2010

Rename a SharePoint 2010 standalone server

To rename a SharePoint 2010 server MSFT recommends using the power shell cmdlet with a brief article. Unfortunately in my case the power shell throws an "object reference" exception which pushed me to explore my good old friend STSADM in 14 hive.

Rename the SharePoint 2010 server using STSADM

stsadm.exe -o renameserver  -oldservername -newservername

Rename the Windows Server 2008 R2

Computer->Properties->Change Settings->Change-> Provide the new Server name and restart the machine

Update Farm credentials using STSADM
stsadm.exe -o updatefarmcredentials  -identitytype configurableid  -userlogin          -password

 Update AAM settings for Central Administration
  • Open central administration, select Application Management in the left pane
  • Select configure Alternate access mappings under Web applications setting
  • Filter the view by "Central Administration" and modify the internal Url to reflect the new Server Name.
If you have created any other web applications then modify the alternate access mapping settings for those URL's

Do an IISRESET and good to go.

Thursday, November 18, 2010

SharePoint on Cloud from Microsoft Online Services

SharePoint Online is a cloud-based service for businesses. In SharePoint setting up a web farm and get it up running form small enterprise was always a challenge in terms of hardware cost, getting the expertise to set up the web farm, capacity planning etc.

Now Microsoft wants to bring SharePoint to the masses by exposing it in the cloud thus it takes care of the infrastructure, scalability of the web farm, maintenance & patching the systems with less or no downtime and calculation of volume licensing(ever did or try to find the licensing math) with as low as 10$.

Reach out to SharePoint Online for small business which provides information related to the small enterprises. Developers can reach out to Developer resource center for understanding developer features available. I believe there should not be major change Developer resource centers with the API for development.

Finally SharePoint also joins the Cloud band. hmm.. result of significant innovation and development in virtualization arena.

Friday, October 22, 2010

Fetching from SharePoint Lists using ACE OLE DB

There are varieties of ways available to access a sharepoint list object model, web services, RPC, DAV. Recently gotta chance to work with Microsoft ACE OLE Db objects, while playing with the object came across a strange connection string from Connectionstrings.com which just provides a connection string for a sharepoint list.

This approach is not officially documented anywhere, I thought of giving it a shot and its working too. Here's the code to display values fetched from SharePoint list using OLE DB data reader.



string connString = "Provider=Microsoft.ACE.OLEDB.12.0;WSS;IMEX=2;RetrieveIds=Yes; DATABASE=http://foo/;LIST={7F72D985-5219-4E8A-AA56-C4473902A333};";
OleDbConnection conn = new OleDbConnection(connString);
            conn.Open();
OleDbCommand command = new OleDbCommand("select * from States", conn);
            OleDbDataReader dataReader = command.ExecuteReader();
            while (dataReader.Read())
            {
               Console.WriteLine(dataReader["Title"]);
             }



This approach is strictly for development environment ONLY.

Tuesday, September 28, 2010

Show communicator status in your custom application pages

When ever we show a username in a custom application page or in a custom web part, adding that small presence aware icon before the user name will be a value addition to the end users which allows to see the person's availability.

An ActiveX control called NameCtrl in Name.Dll is responsible to retrieve the user status and rendering.

Use the following snippet, get the string and render it on your custom page to make the presence aware work for you. Ensure Ows.Js is referenced in your master page, this javascript is responsible for instantiating the ActiveX control and rendering.

public static string GetIMStatusForUser(string personEmail, string personName)
{
string statusJS = String.Format("<span><img border=\"0\" height=\"12\" width=\"12\" src=\"/_layouts/images/blank.gif\" onload=\"IMNRC('{0}')\" id=\"IMID\"
ShowOfflinePawn=1><a href=\"mailto:{0}\">{1}</a></span>",
personEmail,personName);
return statusJS
}

Monday, September 27, 2010

70-542 MOSS 2007 App Development completed

Completed 70-542 Microsoft Office SharePoint Server 2007, Application Development last week end

With SharePoint Server 2010 in the ring, it's late but good to complete the 2007 series before jumping to 2010 bandwagon

Useful links for preparation:

  1. http://paulgalvin.spaces.live.com/blog/cns!1CC1EDB3DAA9B8AA!192.entry
  2. http://thepointyheads.com/2009/10/microsoft-exam-70-542-comprehensive-list-of-training-materials-for-every-section-of-the-exam/

Tuesday, August 24, 2010

How to enable SharePoint to handle the forbidden files ?

We tried to store files which has the (.rules) extension in document library, once we added all these files to the document repository,we tried to download these files by clicking on it. It ended up in an error message stating.

This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden.
The extension '.rules' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /Financial Documents/TestRulesSet.rules
But the Send to->"Download a copy"  option works as expected. When we use this method we are asking the OOB download.aspx page to download the content for us.

 After re-collecting the basics of SPHttpHandler which handles all the SharePoint requests. This handler is forbidding this specifying file type. so the solution is to
Add a http handler before SPHttpHandler which serves this file type as expected

 Open windows explorer , navigate to the virtual directory and open web.config with your favorite text editor

 Find section and the following segment below after the remove block, so after adding the httpHandlers section will look like below

 <remove verb="GET,HEAD,POST" path="*" />
<add verb="*" path="*.rules" type="System.Web.StaticFileHandler" />
<add verb="GET,HEAD,POST" path="*" type="Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler...

 Do an IISReset

Warning : Do understand the risk of exposing these forbidden files using StaticFileHandler

Following is the list of Http handlers which takes care of the frequently used ASP.NET file types
  • trace.axd - System.Web.Handlers.TraceHandler
  • aspx - System.Web.UI.PageHandlerFactory
  • ashx - System.Web.UI.SimpleHandlerFactory
  • asmx - System.Web.Services.Protocols.WebServiceHandlerFactory
  • rem - System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
  • soap - System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory
  • asax - System.Web.HttpForbiddenHandler
  • ascx - System.Web.HttpForbiddenHandler
  • All sharepoint request - Microsoft.SharePoint.ApplicationRuntime.SPHttpHandler
  • Reserved.ReportViewerWebControl.axd -Microsoft.Reporting.WebForms.HttpHandler