Archives

Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Monday, April 18, 2011

Microsoft's Office 365 Goes Open Beta

Microsoft Office 365Microsoft has finally opened the door to its cloud-based Office 365 and is now offering the service as a public beta for anybody and everybody to try out. The beta is available in 38 countries as well as 17 languages. The new beta also follows several months of limited testing with a few thousand businesses that were able to take the service out for an early test drive. After this public beta, Office 365 will officially launch later this year.

Office 365, which was unveiled last October, is Microsoft's attempt at offering businesses a cloud-based alternative to some of the company's more traditional desktop and server products. Office 365 combines Office Web Apps with hosted versions of Exchange and SharePoint as well as Microsoft's Lync product. The Lync product provides the online communication and collaboration element of Office 365.

With all of this, Office 365 is designed to offer a plethora of features including document creation, document sharing, e-mail, IM, online meetings and public Web sites. Microsoft has also included protection in the form of its enterprise ForeFront security client and is also promising a 99.9% uptime for the entire service.

Once Office 365 officially launches it will be offered as two separate plans depending on the size of your company. Small businesses with around 25 employees or less can pay $6 per person per month to receive Office Web Apps and the hosted versions of Exchange and SharePoint. Larger corporations will have to chose from one of four different plans geared toward faculty, staff and students.

In addition to Office 365 being offered as a beta, Office 365 Marketplace is in beta form as well. Office 365 Marketplace is designed to supplement Office 365 and tries to help businesses find apps and services offered by different Microsoft partners. Reports from users already experiencing the beta have noted that everything is working as Microsoft has advertised it to.

Source: CNET - Microsoft opens up Office 365 as public beta

File Server rentals are ideal if your company needs an extra storage unit for company information while you are testing various types of storage solutions.

Whether you need a short-term rental or a long-term lease, we have the right kind of server for your needs.
Read More >>

Friday, December 24, 2010

Installing SharePoint 2010 on Windows 7

I generally do most of my development and “technology exploration” in an environment that reflects the actual production environment as closely as possible – for example, by developing against multiple virtual servers running Windows Server 2008 in a domain configuration. This approach has the advantage of reducing the opportunity for “well, it works on my laptop” style configuration issues when trying to deploy the application into production, but, let’s be honest, it makes life difficult – especially when the “real world” configuration requirements are as onerous as those of SharePoint-based solutions.

Microsoft has documented a way to deploy SharePoint 2010 on a single Windows 7 (or Vista if you prefer) development box, so when I recently needed to do some basic SharePoint development, I decided to ignore my existing virtualized, multi-server SharePoint development and testing environment, and try out Microsoft’s instructions for creating a single-box development environment. For the most part, this went OK, but I did hit a few issues along the way, so I thought it might be useful to document my experience.

First, I installed Windows 7 (64-bit, since SharePoint is 64-bit only!) and then downloaded Microsoft SharePoint Foundation 2010. The download is an executable named SharePointFoundation.exe, which you can simply run if you intend to install on the supported Windows Server platform, but which you need to extract to the file system in order to install on Windows 7 (or Vista). For example, to extract the installation files to a folder named C:\SharePointFiles, I used the following command:

SharePointFoundation /extract:c:\SharePointFiles

Next, I needed to edit the config.xml file provided with the SharePoint files, and add a <Setting> entry to enable installation on a client OS, as shown below:

Picture1 

The SharePoint installation files include a tool to automatically install and configure SharePoint prerequisites, but this only works on the supported Windows Server OS – you can’t use it on Windows 7, so you need to install and configure the prerequisites manually. The first of these is the Microsoft Filter Pack, and it’s included in the extracted files, as shown here:

Picture2

Links to the remaining prerequisites are in the Microsoft documentation, and I simply downloaded and installed the ones I required for SharePoint Foundation on a Windows 7 machine (which included the Sync Framework, the SQL Server 2008 Native Client, and the Windows Identity Foundation).

Next I needed to enable all of the IIS features that SharePoint requires. Microsoft provide the following command, which you can copy to a command prompt window (on a single line) and execute.

start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;
IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;
IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;
IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;
IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ManagementScriptingTools;
IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;
IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;
IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;
IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;
WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;
WCF-NonHTTP-Activation

This enables the required features, which you can verify in the Windows Features Control Panel applet as shown below:

Picture3

Now I was ready to install SharePoint Foundation. I ran Setup.exe and chose the Standalone installation option:

Picture4

After installation is complete, I was prompted to run the SharePoint Product Configuration wizard, and this is where the wheels fell off! The Standalone installation of SharePoint includes the installation of a SQL Server 2008 Express database server instance (named SHAREPOINT) to host the configuration database, but somewhat annoyingly, you need to apply the Microsoft SQL Server 2008 KB 970315 x64 hotfix before you can run the configuration wizard. However, even after doing this, I still found that the SharePoint Products Configuration wizard failed to connect to the database server in order to create the configuration database. In desperation, I upgraded the SQL Server 2008 Express instance that had been installed to SQL Server 2008 R2 Express – still no luck.

My investigations resulted in finding a number of useful blog articles, which are listed below – none of these actually solved my specific problem, but they contain some really useful tips!

After some poking around, I discovered a command-line version of the configuration wizard in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN folder named psconfig.exe, and by examining its parameter info I discovered a standaloneconfig value for the cmd parameter, as shown below:

Picture5

This seemed to solve my problem, and I now have a fully configured SharePoint Foundation 2010 environment on a Windows 7 virtual machine, as shown below.

Picture6

All-told, it took me the best part of an afternoon to create my “simple” SharePoint development environment – but to be fair, a large percentage of that was spent scrabbling around to try to figure out how to get the configuration wizard to work. Hopefully, your installation will go a little more smoothly!

Happy Holidays!

del.icio.us Tags:
Read More >>

Thursday, December 2, 2010

Serious Guidance for Serious SharePoint Developers



Earlier this year, I was lucky enough to spend several months working with the patterns & practices team at Microsoft, producing guidance for developers and architects on working with SharePoint 2010—check out the Developing Applications for SharePoint 2010 pages on MSDN. The guidance includes:


  • Documentation that provides deep technical insights into core aspects of SharePoint 2010 development
  • Deployable reference implementations with a realistic level of complexity
  • "How To" documentation on tricky tasks
  • A library of utility classes that you can use in your own SharePoint applications

The guidance is primarily aimed at experienced SharePoint developers and architects who want a more sophisticated level of guidance. Rather than explaining the basics of SharePoint development, it aims to give you the information and resources you need to make effective architectural and implementation decisions. For example, the topics on sandboxed solutions provide a detailed insight into how sandboxed assemblies are loaded and executed, how resource monitoring and throttling criteria are applied, and how low-privileged process accounts together with CAS policies restrict the functionality of sandboxed solutions. In light of these insights, it goes on to explore exactly what you can and can't do with sandboxed solutions. Patterns & practices go to great lengths to make sure their guidance has real world relevance—the core team included two SharePoint MVPs, Todd Baginski and Rob Bogue, and every chapter and component was reviewed by an external "advisory council" consisting of leading industry figures in the world of SharePoint.


We've now distilled the core content from this guidance into a new book, Designing Solutions for SharePoint 2010. If you're new to SharePoint development, this probably isn't the book for you. However, if you already know your SPSite and your SPWeb and you're looking for deeper technical insights, then this could be a valuable addition to your bookshelf.


Read More >>

Tuesday, August 3, 2010

SharePoint Foundation 2010, error 7ba54aea-5d64-

Hi

I have a SPF 2010 with a SQL 2008 cluster.

I use the url: http://server_name

But I did an alias in the DNS, so I can use the url http://site

But Now some areas in the SPF 2010 fails:

image

Everything goes well with the server name.

I hope, It is a sPF 2010 configuration that I don’t know

Regards

sAnTos

Read More >>

Thursday, July 9, 2009

SharePoint, Search and Loopback Checking

Recently a client encountered a problem on a single server MOSS deployment on Windows Server 2008. After installing MOSS SP2 and some Windows updates, the client reported that:
  • The search service wasn't returning any results.
  • They couldn't access the SSP administration page from the server.

This turned out to be the loopback checking feature in IIS. This feature prevents you from accessing a Web site with a host header from the same machine - for example, you can access http://machinename/default.aspx, but not http://hostheader/default.aspx. When you attempt to access a site under these conditions, you'll be prompted for credentials three times and then have access denied with a 401.1 Unauthorized: Logon Failed error. The giveaway was that the Central Administration site was set up to use the machine name, whereas the SSP site was set up to use a host header.

Because this is a single server environment, the search service is attempting to crawl sites, by host header, that are hosted on the local machine. In each case, access is denied with a 401.1 error and you end up with a very empty search index.

This issue became a fairly well known problem for SharePoint administrators on Windows Server 2003 environments, and usually arose when the server was upgraded to SP1. I've never come across the issue in a Windows Server 2008 environment before - I guess an update must have triggered the loopback checking feature in IIS7, but I'm surprised it wasn't enabled already.

Anyway, I followed the workaround here (Method 1), restarted the IIS Admin service, started a full search crawl and we're up and running again.

Read More >>

Friday, June 5, 2009

SharePoint and Tagging Content

Plenty has been written in the Blogosphere about Web 2.0 and more recently the idea of Enterprise 2.0 in which the kind of functionality that we're now used to on Wikipedia, Facebook, Twitter, Delicious and so on are used within an organisation's intranet and extranet to improve collaboration. You'll also see Enterprise 2.0 called enterprise social software. It's not a surprise; most people reading this will be users of many of these services and know how helpful they can be for keeping in touch, finding obscure information, and meeting new "friends". It's really easy to see how such technologies would be useful on an intranet, particularly in a large, global organisation where employees can feel lost or isolated. When users know about blogs, wikis and social networking, they'll be comfortable with similar tools for sharing knowledge with their colleagues should they should start using them rapidly.

SharePoint, particularly MOSS, is an ideal platform for Enterprise 2.0 and supports many of the features required straight out of the box. Take a look, for example at the list of features in the Wikipedia article on Enterprise 2.0 (a list which was taken from Andrew McAfee):

  • Search: allowing users to search for other users or content.

    SharePoint has market-leading search functionality for locating content and MOSS includes people search for locating users.

  • Links: grouping similar users or content together.

    In My Site you can identify colleagues and those who have things in common with you. Content can be grouped in lots of ways.

  • Authoring: including blogs and wikis.

    SharePoint includes site templates for blogs and wikis. They're very rapid to set up. There's very rich functionality for collaborative authoring of documents.

  • Extensions: recommendations of users; or content based on profile

    MOSS has lots of ways to do this in My Site.

  • Signals: allowing people to subscribe to users or content with RSS feeds

    Any SharePoint list or document library can have an RSS feed.

  • Tags: allowing users to tag content

    Bad news: SharePoint is a little lacking here and it's this that I want to discuss in this article.

Take the default SharePoint blog template as an example: When you add or edit a post, there's no field for tags. You can place the post in a category, but that's not the same thing because the categories are pre-determined and you can't create a new one on-the-fly. Also you can only put the blog entry in a single category, but you often want to tag it with several different words.

In Web 2.0 there are two kinds of tags. The ones added to content by the author are stored with the content. For example, I've tagged this entry with the word "SharePoint" so that when you click on SharePoint in the word cloud, it will appear. Then there are tags that readers add to the content. Since they only get read access to the site, readers can't store their tags with the content. Instead they save a list of links on a site like Delicious and add tags to those links. I'll deal with these two types of tagging separately.

Author Tags

Of course it's straight forward to add a new column to SharePoint for tags. It's just a text field after all. In the blog homepage click Manage Posts, then under Settings, click Add Column. When you edit a blog entry you'll be able to edit this new field. In most blogging tools, this would be a comma separated list.

Display is a little harder. It would be relatively simple to write a Web Part that displays the tags for an item. This would work when a single blog post is displayed (The view where comments are visible) but you wouldn't see it in the list of all posts. To display tags here, under each post, you'd have to write your own Web Part to replace the Posts Web Part, and include a list of tags for each post. This isn't advanced programming but it would take a little time to get right.

Perhaps more importantly there is no tag cloud display in SharePoint out of the box. I know you've seen a tag cloud before because there's one just to the left of this text. It shows a list of all the tags used in the blog and each is sized according to how often it has been used (SQL Server is the most popular tag as I write). Again, it isn't hard to create a Web Part that does this: you'd need to loop through all the entries in your blog, evaluating and counting the comma-separated terms in your Tags column. Then you output text and probably render style attributes to size each term.

I'm not showing you example code for all this because plenty of people have already written some. Notably the people at wsssearch.com whose tagging controls are part of the Community Kit for SharePoint. Here's their Tag Cloud control running in the standard SharePoint blog site:



Two things to point out about these controls: firstly, they don't just work with blog posts. You could use them with announcements, contacts, or just about any content type including your own custom content types. Secondly, they're open source, which means you can use them as a starting point for more ambitious functionality. For example, you can have a tag cloud that linked to content from across a site collection or even across your whole enterprise. You'd have to be careful about indexing and so on to achieve good performance but with care this could be a really useful control to show users hot topics in your organisation.

User Tags

Delicious-style, user tags are in some ways more interesting than author tags because they work in your community of readers and this is really what Web 2.0 and Enterprise 2.0 are all about. It allows you to find people with similar interests to your own and find links that they like: these will probably help you.

SharePoint is already excellent at finding people, particularly when My Sites are widely used. You can find people with similar skills or who have worked on similar projects or have other things in common with you. You can search by name, department, skill, or any other managed property. So what we need is a simple way for users to save their favourite links and tag each one. These can be displayed on the user profile.

Each user will need a new list in their My Site page, with columns for the URL, the tags (probably in a comma-separated list as before), and then maybe Name and Description. Delicious has Title and Notes fields. There's a good blog entry on deploying list templates to My Sites here if you need help with this.

So far, so simple. Now users can find people like them and see their favourite links and tags. We must make this system effortless to use because it will only be helpful when lots of users add all their favourite links and continue to add them as they find new ones. Users' links are stored in their browser favourites or bookmarks so it's essential to give them a tool for importing these into their My Site profile. How would this work?

On Delicious you export a list of favourites from the browser using its standard tools. You then upload this to the server and tag the imported links. If a link is in a folder, for example one called "SharePoint", that name is added as a tag. But you should then review all the imported links and add tags as you need. This kind of solution would be easy to implement in SharePoint in a Web Part. You would add the ASP.NET FileUpload control to the Web Part. When the user clicks "Upload" you can get this file from the FileUpload.PostedFile property and parse it for all the links and folder names. For each link you'd add a new entry to the user's list in their My Site.

If you build such a solution, you should give careful attention to usability. For example, having uploaded a hundred favourites, a user won't like editing each one individually. You should give them a form with arrow controls that enable them to move to the next and previous entry with a single click. You should give them a list of the other tags they've used before: a single click on the tag adds it to the list. You should use Silverlight or AJAX to maximise the responsiveness of the form and cut down on page reloads.

Finally, consider how to make these tags available and interesting to users. Again a tag cloud control will be really helpful, but this one would have to evaluate many more tags spread throughout a large number of My Sites (each of which is a separate Site Collection). Think carefully about performance and indexing to ensure this cloud runs fast. Again, I'd use the Community Kit for SharePoint code as a starting point. I'd also suggest a hierarchical control to enable browsing tags by user, without having to open multiple My Sites, and other displays such as "Lastest 20 tags", "Most popular 20 tags" and so on. Placing these controls on key intranet pages should help users communicate and generate a buzz around hot topics.

Conclusion

So SharePoint 2007 does indeed do full Enterprise 2.0 functionality with a little bit of custom coding. I think we can safely expect SharePoint 2010 to improve on this. It's almost certain to have a Tag Cloud control built-in for example. But it may be a year or more before your organisation upgrades and as I've shown here, we can make big strides right now without a massive effort. Also, you should be considering the Enterprise 2.0 concepts because they enable users themselves to make their intranet a compelling place to surf. This will be a big topic in SharePoint 2010.

Links

Wikipedia Enterprise 2.0 Article

Delicious

Community Kit for SharePoint

Read More >>

Tuesday, June 2, 2009

Using Microsoft Bing Maps in SharePoint

The last time I blogged I wrote about SharePoint and Google Maps – specifically how to display maps in a SharePoint Web Part. Since you frequently have geographical information stored in SharePoint, most often as postal addresses, this is a really powerful addition to your developer arsenal. But Google Maps is only one of the mapping providers you can use in this way, for example, there's MapQuest and Yahoo! Maps.

Microsoft's mapping solution is called Bing Maps. Just last week Microsoft announced it is rebranding Virtual Earth as Bing Maps. The API that you use to place Bing Maps on your Web site is now called Bing Maps for Enterprise. For those of you who've developed Virtual Earth code before, you'll be pleased to know there's not much change. A few people asked me how to use this technology in SharePoint – it can be done in a very similar way to Google Maps and in this post I'll cover the differences.

Review of Architecture

As for the Google Maps solution I described in my last post, the interesting part about this task is getting a largely server-side technology like SharePoint to work with a client-side technology like Bing Maps. Suppose you have some search results, each of which has a latitude and longitude, that you want to display in a list and on a map. In a conventional Web Part you'd loop through the results in server-side ASP.NET code to build an HTML list to display on the browser. Bing Maps uses JavaScript on the client to add pushpins like this:

var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());

shape.SetTitle('A new pushpin');

shape.SetDescription('This is just to demonstrate pushpins');

map.AddShape(shape);

So the question is, how to get client-side code to loop through a collection that only exists on the server?

Our approach is to render an XML island that contains relevant information for each search result. The client side code can locate this island and loop through it, adding a pushpin or another shape for each entry. We'll put the JavaScript in a separate file but embed it as a resource in the .NET assembly as we did for Google Maps.

You could also consider an AJAX-style approach to this problem: this would consist of a Web service that receives search terms and returns results. Client-side code could both render the list and the pushpins on the map and you get all the improvements in responsiveness that are achievable with good AJAX coding. One thing to watch out for: the built-in SharePoint Web Services are not enabled for AJAX so you'd have to write your own.

Most of the coding for this Bing Maps solution is exactly the same as for Google Maps, so you should read this after digesting the previous post. The following tasks are exactly the same:

  • Rendering the XML Data Island.
  • Registering and embedding the scripts in the Web Part assembly.
  • Parsing the XML Island.

That leaves us with three tasks that are different for Bing Maps. I'll describe these below.

Map Results Web Part

To put a Bing Map on a static Web page you must first link to the scripts library:

<script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" type="text/javascript" ></script>

Then you must use a <div> tag to position and size the map:

<div id='myMap' style="position:relative; width:800px; height:600px;"></div>

These can both be rendered in server-side code like the following in your map Web Part's Render method:

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
      //Render the script tags that link to Google Maps API
      writer.WriteLine("<script " +
           "src=\"http://ecn.dev.virtualearth.net/mapcontrol/" +
            "mapcontrol.ashx?v=6.2\" " +
            "type=\"text/javascript\"> </script>");
      //Render the div that will display the map
      writer.Write("<br /><div id=\"map\" " +
            "style=\"position:relative; width: 800px; height: 600px\" ></div>");
}

Loading the Map

This JavaScript function loads and sets properties for the map. This should go in the JavaScript file you have embedded in the Web Part assembly:

var map;

function loadMap(){
      //Create the map
      map = new VEMap("map");
      //The default latitude and longitude.
      var latlong = new VELatLong(54.59088, -4.24072);
      //The default zoom level
      var zoomlevel = 5;
      map.setCenterAndZoom(latlong, zoomLevel);
      //Add the controls
      map.SetDashBoardSize(VEDashboardSize.Normal);
      map.LoadMap();
      //Parse the XML in the HTML data
      parseXmlIsland();
}

The parseXmlIsland function is just like that for Google Maps because the XML is the same. For each result in the XML island, it adds a pushpin.

Adding Pushpins

This addPushPin function inserts a new pin at the longitude and latitude specified. The parseXmlIsland function calls this for each result:

function addPushPin(Title, Path, Latitude, Longitude){
     
      //Formulate the HTML that goes into the caption window
      var infoHtml = "<a href="http://www.blogger.com/">" + Title + "</a>";
      //Add the pushpin
      var pinLatLong = new VELatLong(Latitude, Longitude);
      var pin = new VEShape(VEShapeType.PushPin, pinLatLong);
      pin.SetTitle("<h2>" + Title + "</h2>"
      //Add an info window
      pin.SetDescription(infoHtml);
      //Add pushpin to the map
      map.AddShape(pin);
}

Conclusion

So you can Bing Maps in SharePoint using just the same approach as Google Maps. The coding details have differences but the overall architecture and some of the tasks are identical. All the code in both my posts uses latitude and longitude, but both APIs provide geo-coding functions that can convert an address into polar co-ordinates if you need it.

Links

Windows SharePoint Services Developer Center

SharePoint Server Developer Center

Bing Maps Interactive SDK

Read More >>

Thursday, May 28, 2009

Using Google Maps to Display Geographical Information in SharePoint

Google Maps provides a really simple way to display geographical information, such as a set of pinpoints or a route, in the context of the surrounding geography, and developers can use it for free on Internet-facing sites. If you have data stored in Microsoft SharePoint products or technologies that includes geographical information, you should consider if a map display might help your users. I'm going to show you how to use Google Maps with the SharePoint user interface and demonstrate some simple coding techniques.

Microsoft's flagship SharePoint product is Microsoft Office SharePoint Server 2007 but you could easily use maps in the free Windows SharePoint Services 3.0 or other products based on SharePoint, such as Search Server 2008.

Take a good look at all the mapping solutions before starting to code. You may prefer Virtual Earth's user interface or find that Yahoo! Maps have more detail in a location that is important to you. I've coded Google Maps for a customer, and it is the most popular solution, but if you chose Virtual Earth instead the only difference would be in the JavaScript code I describe.

I'll concentrate on the use of Google Maps to display search results but the methods described can be applied other sources of data such as a SharePoint list, an Excel spreadsheet, or a Business Data Catalog (BDC) connection.

General Architecture

SharePoint is built on the ASP.NET 2.0 server-side development technology and its user interface is built from ASP.NET Web Parts. Web Parts allow administrators and users to customize the user interface to match their needs. They can add or remove Web Parts or rearrange them on the page. In the Web Part Gallery, site administrators can control which Web Parts are available. When you develop user interface components for SharePoint you should create them as Web Parts to inherit this flexibility automatically. You should also consider whether to create more than one Web Part to encapsulate different aspects of functionality that users can easily differentiate.

As an example consider a search tool for geographical data. When the user clicks "Search" the tool presents a list of results that match their terms as you might see in an Internet search engine or the SharePoint Search Center. However this tool also presents a Google map with the results pinpointed. This tool might warrant three Web Parts; one for the search terms, one for the results in a list, and a final one for the results on a map. In this architecture users or administrators could show just the list, just the map, or both displays.

Unlike Web Parts, Google Maps are coded in client-side code. JavaScript is used in the browser to create and position the map, add pinpoints, add captions, and draw shapes. This is what makes life interesting. Your Google Maps SharePoint solution must address how to communicate between server-side Web Parts and client-side JavaScript. You could, for example, publish a Web Service on the server and have client-side code query it and present results. AJAX would provide a lot of help with this. In the method I used, a server-side Web Part generates XML and renders it as an island amongst the SharePoint HTML. In the browser, JavaScript can locate this island and use it to draw the map and add pinpoints.


Search Results Web Part

In most search tools, results are presented in a list with links to each, a short description, and sometimes other fields. To build a SharePoint Web Part that displays search results, you submit a query by using a Microsoft.SharePoint.Search.Query.FullTextSqlQuery object. This returns a ResultTable object through which you must loop to evaluate each individual result and display them to users.

XML Data Island

As your code loops through the ResultTable, you can build the XML to place as an island in the Web page that will be returned to the client. To do this, create a System.Xml.XmlWriter object and configure it with a corresponding XmlWriterSettings object:

//Create the XML Writer Settings for configuration

XmlWriterSettings settings = new XmlWriterSettings();

settings.Encoding = System.Text.Encoding.UTF8;

settings.Indent = true;

settings.OmitXmlDeclaration = true;

//This string builder will be used to render the XML

resultsForMap = new StringBuilder();

//Create the XML writer

XmlWriter writer = XmlWriter.Create(resultsForMap, settings);

Then you can write the start element for your XML:

writer.WriteStartElement("MapResults", "my.namespace");

Looping through the DataRow objects in the ResultTable.Rows collection, you can add XML elements with the properties you need. For example:

foreach (DataRow currentResult in myResults.Rows)
{
      writer.WriteStartElement("Result");
      writer.WriteElementString("Title",
            currentResult["Title"].ToString());
      writer.WriteElementString("Path", path);
      writer.WriteElementString("Latitude",
            currentResult["SupplierLatitude"].ToString());
      writer.WriteElementString("Longitude",
            currentResult["SupplierLongitude"].ToString());
      writer.WriteEndElement();
}

You must remember to end the XML and flush the writer:

writer.WriteEndElement();
writer.Flush();

Your XML is now flushed to the StringBuilder object (named resultsForMap in the above example). To render this string on the SharePoint Web page you can use an ASP.NET Label like this:

returnedXmlLabel.Text = "<xml id="\">" +
      resultsForMap.ToString() + "</xml>";

The ID you use for this XML island allows JavaScript code to locate it when the map is rendered on the client.

Map Results Web Part

Since the work of populating the map with points and captions is done in client-side code, there is little to be done in ASP.NET code for the Map Results Web Part. However it is necessary to render a <div> tag for the map, and a <script> tag for the Google Maps code library. This <script> tag is where you must render the Google Key associated with your Google Maps account.

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
      //Render the script tags that link to Google Maps API
      writer.WriteLine(String.Format("<script " +
            src="\http://maps.google.com/maps?" +
            file="api&v=2&key={0}\ " +
            type=\"text/javascript\"> </script>",
            "Your key here" ()));
      //Render the div that will display the map
      writer.Write("<br /><div id=\"map\" " +
            "style=\"width: 800px; height: 600px\" ></div>");
}

Registering and Embedding the Scripts

In the Map Results Web Part, you must also ensure that the JavaScript, which generates the map and populates it with pinpoints, executes when the page reaches the client. ASP.NET 2.0 provides an elegant way to do this: you can embed script files as resources in the same assembly as the Map Results Web Part. This makes deployment simple, because the script is part of the assembly.

You must complete several steps to embed a script file in your Web Part assembly:

  1. Add a JavaScript file to the Visual Studio project and write the JavaScript Code.

    This file is where you place all the Google Maps code. For examples of such code, see "JavaScript Files" below.

  2. Add Web resource entries to the AssemblyInfo.cs file.

    This file contains information about the assembly such as version numbers. You can add a reference to a script file like this:

    [assembly: WebResource("MyNameSpace.MapScripts.js",
          "text/javascript", PerformSubstitution = true)]

  3. In your Map Results Web Part, register the script resource.

    You should do this in the OnPreRender method:

    protected override void OnPreRender(EventArgs e)
    {
          //Register the JavaScript file
          Page.ClientScript.RegisterClientScriptResource(
               this.GetType(), "MyNameSpace.MapScripts.js");
    }

  4. Make sure the script runs whenever the page loads.

    You do this by registering the script as a startup script. Add the following line to the Map Result Web Part in the Render method:

    this.Page.ClientScript.RegisterStartupScript(
          this.GetType(), "MapScriptsStart", "loadMap();", true);

    
 

JavaScript Files

We now have an XML island rendered in the SharePoint Web Part that contains all the results that must appear on the map. We have also embedded a JavaScript file in the Web Part assembly to execute when the page loads on the client. The final task is to write JavaScript in the embedded file that loads the Google Map and add pinpoints and other objects.

Loading the Map

First, create a global variable to reference the map itself. You will need this throughout the script file:

var map;

Next create a function to load the map. This should match the function you specified in the RegisterStartupScript method in the previous section:

function loadMap(){
      //Create the map
      map = new GMap2(document.getElementById("map"));
      //Centre it on default latitude and longitude.
      map.setCenter(new GLatLng(54.59088, -4.24072), 16);
      //Set a default zoom level
      map.setZoom(5);
      //Add the controls
      var mapControl = new GLargeMapControl();
      map.addControl(mapControl);
      map.enableScrollWheelZoom();
      map.addControl(new GMapTypeControl());
      map.setMapType(G_SATELLITE_MAP);
      //Parse the XML in the HTML data
      parseXmlIsland();
}

Parsing the XML Island

The last line of the above code calls a separate parseXmlIsland function. This function locates the XML island and loads it into a variable. This must be done slightly differently depending on the user's browser:

var xmlIsland;
try //Internet Explorer
{
      xmlIsland = new ActiveXObject("Microsoft.XMLDOM");
}
catch (e)
{
      try //Firefox, Mozilla, Opera etc.
      {
            xmlIsland =
            document.implementation.createDocument("", "", null);
      }
}
xmlIsland.async = "false";
xmlIsland.validateOnParse = "false";
xmlIsland.loadXML(document.getElementById("resultsformap").innerHTML);

Setup some variables and get all the results nodes you placed in the XML:

var Title, Path, Latitude, Longitude;
var resultNodes = xmlIsland.getElementsByTagName("Result");

Now, loop through the node, storing relevant information:

var resultNode;
var resultNodeChild;
for (i = 0; i < resultNodes.length; i++) {
      resultnode = resultNodes[i];
      for ( j = 0; j < resultNode.childNodes.length; j++) {
            resultNodeChild = resultNode.childNodes[j];
            switch (resultNodeChild.nodeName) {
            case "Title":
                  Title = resultNodeChild.text;
                  break;
            case "Path":
                  Path = resultNodeChild.text;
                  break;
            case "Latitude":
                  Latitude = parseFloat(resultNodeChild.text);
            case "Longitude":
                  Longitude = parseFloat(resultNodeChild.text);
                  break;
            }
      }
      //Add a point for this result
      addPinPoint(Title, Path, Latitude, Longitude);
}

Adding Pinpoints

The above code calls the addPinPoint function for every result in the XML island. This function adds a pinpoint to the Google map in the standard way:

function addPinPoint(Title, Path, Latitude, Longitude){
      //Set up the icon
      var myIcon = new GIcon(G_DEFAULT_ICON);
      //Select the right icon
      myIcon.image = "mapimages/myPinPointIcon.png";
      myIcon.iconSize = new GSize(12, 30);
      myIcon.shadow = "mapimages/myPinPointShadow.png";
      myIcon.shadowSize = new GSize(23, 30);
      myIcon.iconAnchor = new GPoint(6, 30);
      markerOptions = { icon:myIcon };

      //Formulate the HTML that goes into the caption window
      var infoHtml = "&lta href="http://www.blogger.com/">" + Title + "</a>";

      //Add the marker
      var point = new GLatLng(Latitude, Longitude, false);
      var marker = new GMarker(point, markerOptions);

      //Add an info window
      GEvent.addListener(marker, "click", function () {
            marker.openInfoWindowHtml(infoHtml);
      });

      //Add the overlay
      map.addOverlay(marker);
}

Licensing Considerations

The techniques I've outlined illustrate that Google Maps can be easily integrated into a SharePoint site and become a valuable addition to SharePoint functionality. However, before you develop such a solution, you must investigate licensing restrictions fully. This section describes the main issues and alternative map providers.

Licensing Google Maps

Google Maps is free for use on Internet-facing, non-subscription sites. If you use SharePoint to host your organisation's main Web site, or more targeted sites for departments, subsidiaries, or products, you can use Google Maps for no charge on pages with no access restrictions.

Google Maps does not allow free use on any password-protected page or on intranet sites. In such cases you can still use the technology, but you must take out a Google Maps for Enterprise license. Google Maps for Enterprise is licensed on a per-concurrent-user basis.

Microsoft Virtual Earth and Other Providers

Microsoft's Virtual Earth service competes directly with Google Maps and works in a similar way. There is an approximately equivalent set of features and maps are drawn and populated by using client-side code just like Google Maps. To use Virtual Earth with SharePoint your general approach can be identical to that described above although you must rewrite the JavaScript code to use the Virtual Earth classes and methods. On the intranet, Virtual Earth is licensed on the basis of total users.

Yahoo! also have a mapping service. This can be used free on both Internet and intranet sites so you should consider it carefully for SharePoint enterprise content management or knowledge management solutions restricted to your internal users. Yahoo! Maps cannot be used in applications for which you charge users. There are also other alternatives, such as PushPin.

Summary

Google Maps represents the easiest way to display geographical data on Web sites, including those hosted in Microsoft SharePoint products and technologies. If you carefully plan how to integrate the server-side SharePoint technology with the client-side Google Maps code, you can easily integrate the two and generate a rich user experience for geographical data.

Links

Windows SharePoint Services Developer Center

SharePoint Server Developer Center

Google Maps API Documentation

Read More >>

Wednesday, January 7, 2009

SharePoint – Redirect to Secure Channel on Login

A couple of weeks ago, one of our IT guys was looking into hosting blog sites on Windows SharePoint Services 3.0 (using the CKS:EBE blogging engine – well worth a look). We started running through his requirements.

"We need read-only access for anonymous users." Fine.

"We need Forms auth accounts for contributors." No problem.

"We need to redirect users to a secure channel when they log in." OK, this is more challenging.

We can use Web application zones to support multiple access mechanisms, but how do we redirect users between zones when they sign in? This takes a little more trickery.

Let's start with a brief recap on SharePoint zones. Generally, there's a one-to-one mapping between a SharePoint Web application and an IIS Web site. The IIS Web site takes care of user authentication (for Windows auth at least), SSL certificate mapping, and so on. The SharePoint Web application takes care of authorization and serves up content. You can think of the IIS Web site as providing a specific route to the SharePoint Web application, through a specific URL, protocol (http vs. https), and authentication mechanism.

So, what happens if we want to provide more than one route to our SharePoint Web application? In the case of our blog site, we need to provide at least two routes – an http channel for anonymous access, and an https channel for registered users. In other words, we need to map our SharePoint Web application to at least two IIS Web sites. This is where zones come in – when you extend a SharePoint Web application to a new zone, you are effectively mapping it to an additional IIS Web site (with a corresponding configuration file).

In our case, we actually need three zones:


  • A default zone that uses Windows authentication to provide search support (more on this later).
  • An extranet zone to provide secure, forms-authenticated access to registered users.
  • An internet zone to provide read-only access to anonymous users.




So – why the redundant default zone? Because the SharePoint 2007 search service can't use forms authentication for search crawls. If you want to use forms authentication with SharePoint, you must still configure at least one zone for Windows authentication. Furthermore, the Windows authentication zone must be at the top of the list – if you configure the default zone for forms authentication, the search service will try this first and the indexing process will fail. In short, always configure your default zone for Windows authentication.

Now, let's get down to details. I don't want to reinvent the wheel here, so I'm going to assume you can create and configure the default zone and the extranet zone. If you're looking for walkthroughs on zones and forms authentication, the SharePoint Products and Technologies Team Blog has a good post here. In this post, I want to focus on how to redirect users between zones when they sign in.

So, we've got a default zone configured for Windows authentication. Our search service uses this zone to index our blog sites. We've also got an extranet zone configured for forms authentication. Our contributors use this zone to sign in over a secure channel and post content. Next, we need to create an internet zone that:


  1. Allows anonymous users to read blog entries.
  2. Redirects users to the extranet zone when they click Sign In.

Number 1 is straightforward. Number 2 gave me a headache. I looked at various ways of redirecting users on sign in. I tried customising the Welcome.ascx control in the Control Templates folder, but I wouldn't recommend opening that particular can of worms. As it turns out, all it requires is a minor change to the configuration file. First, here's a high level overview of how we configured our internet zone:

  1. Extend the Web application to a new zone, with a host header of http://www.blogs.contoso.com/.
  2. Configure the policy settings for the new zone to deny write permissions to unauthenticated users.
  3. In IIS, enable anonymous access and Windows authentication (a temporary measure) for the Web site that corresponds to the internet zone.
  4. Browse to the site collection using the internet zone URL, sign in, and enable anonymous access at the site collection level.
  5. Go back to IIS, and clear all authentication types except anonymous access for the site that corresponds to the internet zone.
Now for the special move. Open the Web.config file for the internet zone Web site and locate the authentication element. It should resemble this:

<authentication mode="Windows" />

Change the authentication element to use forms authentication – but don’t add the connection strings, role manager details, membership provider details and so on. Set the login URL for the authentication element to point to the login page for the extranet zone:

<authentication mode="Forms">
<forms loginUrl="https://extranet.blogs.contoso.com/_layouts/login.aspx" />

</authentication>

This provides the behaviour we're looking for. If you access the site anonymously and click Sign In, you’re redirected to the secure URL and authenticated against the membership provider. You’re then redirected back to the same relative URL, but in the secure zone – e.g. if you were browsing http://www.blogs.contoso.com/jasonl, you click sign in and authenticate yourself, and you’re redirected back to https://extranet.blogs.contoso.com/jasonl. Same page, different access mechanism.

How does it work? When the Sign In control redirects you to the login page, it includes the site-relative URL of the page you were visiting as a querystring. When you provide valid credentials, the login page will attempt to send you back to the page you came from – however, because it only has the site-relative URL, it has no idea which zone you came from. As a result, you're redirected to the correct page, but via the secure extranet zone rather than the original internet zone. The end result is you can only access the site anonymously over http, and you can only access the site as an authenticated user over https – perfect.
Read More >>

Tuesday, November 25, 2008

Software-plus-services equals?

Microsoft has really gone for the cloud (http://www.microsoft.com/azure/windowsazure.mspx), but are its ideas for online services really down to earth?


There have been various online services from Microsoft for a while now, including a range of offerings under the "Live" umbrella. In this post, I want to look at the importance of Microsoft's distinction between Software plus Services and Software as a Service as a description for services such as Microsoft Exchange Online and Microsoft SharePoint Online.

Firstly, Exchange and SharePoint online services are supplied as part of the Microsoft Online Services brand (http://www.microsoft.com/online/default.mspx), and there are several ways to obtain these services; the Business Productivity Online Suite (BPOS), for example, includes Microsoft Exchange Online, Microsoft SharePoint Online, and Microsoft Office Live Meeting. Secondly, Microsoft Online Services uses a subscription model, and you pay monthly for per-user access to any of the online services; the Microsoft Online Services licensing model lets you assign licenses to just those users who really need online access to secure Exchange, SharePoint, and other services.

So, are Microsoft Online Services an example of Software as a Service (SaaS)? Well no, at least not in the sense that SaaS is usually used, which is to define software delivered over the Internet and which eliminates the need for local application installation and maintenance. However, Microsoft Online Services does share a cost model with SaaS, in that you are in effect paying monthly rental on your services. The reason Microsoft describes Microsoft Online Services such as Microsoft Exchange Online and Microsoft SharePoint Online as Software-plus-Services, is that this is a hybrid model – some real local software and some "out there" services.

Moreover, Microsoft Online Services is a hybrid in more ways than one. Perhaps most importantly, you get the hybrid benefits of always-available hosted services out there in the "cloud" combined with the functionality of local client software – the full Microsoft Office experience on your desktop for interacting with local or online Exchange and SharePoint servers. Compare this to the Google applications model, where everything is through the browser – or at least until Google Gears-powered offline access is extended to all types of documents. But Microsoft Online Services is also a hybrid in another way; you can choose just how much of your local services you actually migrate to the online environment. For example, although you might be using Exchange online, this doesn't stop you using local Exchange servers as well and you can choose which of your user's mailboxes get to be accessible through Exchange online. Your hybrid environment also gets to share resources, so that your Exchange Global Address List (GAL), for example, is available to online and local clients.

The hybrid Software-plus-Services model certainly has the potential to deliver the best of both rich local client software and online services, and although this model doesn't completely eliminate local software support requirements (unlike SaaS), it does offer the potential to significantly reduce infrastructure overheads.

And it is the infrastructure issues that are really at the heart of the Software-plus-Services model; if I've still local software to support, the big question is why bother? Surely it is easy enough to set up Outlook Web Access (OWA) for your own Exchange servers, or to publish a SharePoint site which is accessible outside your perimeter network? Well easy if you've got the resources and the experience, but for many smaller organizations dealing with the security implications can make it difficult to justify. If the pricing suits your organization, using a hosted service could make a lot of sense.


Read More >>