Thursday, August 27, 2009

Excel Services :Example

Excel Services has several offerings and the one I would like to discuss in this post is how useful Excel Services programming could be for a Business.
A person in an organization could define business logic and models on an excel spreadsheet .A developer could create a user interface for an end user to use the logic and get results.The developer could do this by calling the Excel Services web service to get the logic from the spreadsheet, perform calculations and publish the results on a user interface.
Whenever the business logic needs to be changed there is no need for the developer to be involved . A person can just go and modify the logic or rule and the excel services would work with the new logic automatically.

A very common example of Excel Services to demonstrate the same is "an Excel Services Mortgage Calculator".
To refer to the same you can go to:http://msdn.microsoft.com/en-us/library/aa973804.aspx

MOSS 2007 : psconfig.exe

Use and Need of psconfig.exe in MOSS 2007

In SharePoint Products and Technologies, you can use the psconfig.exe command-line tool as an alternate interface to perform several operations that control how the SharePoint Products and Technologies are configured. You must be a member of the Administrators group on the local computer to perform these operations.

Here is a scenario I found where one would use psconfig instead of the MOSS graphical interface.

For example, if you want to use a SQL server installed on different domain than SharePoint, without using domains trust relationship, you have to connect to the SQL instance using SQL authentication. When creating, or connecting a server to a farm, the only way to use SQL authentication is to use psconfig.exe (located at 12\bin directory) tool.

More information on psconfig.exe:http://technet.microsoft.com/en-us/library/cc263093.aspx.

You can also refer to :http://blogs.msdn.com/yvan_duhamel/archive/2008/11/24/configuring-your-sharepoint-farm-through-psconfig-command-line-tool.aspx


Tuesday, August 25, 2009

Excel Services error: You do not have permissions to open this file



I was configuring Excel Services and got this error

The following steps helped me get rid of it:

1. Open Central Administration -> go to Operations tab
- ensure that the Excel Service is running

2. Open Central Administration -> go to your configured Shared Service -> click Excel Service Settings
- File Access Method: ensure that it is not using Impersonation, instead the Option Process Account should be enabled.

3. Open Central Administration -> go to your configured Shared Service -> click add new trusted file location
- field URL: here you can specify a report library or the whole portal
- Location Type: should be Windows SharePoint Services
- Children trusted: defines whether the children should also be trusted or only the definied path

I had spaces in my doc lib name so I tried adding only the top site name and having its children trusted..it worked for me

Monday, August 24, 2009

MOSS 2007 :Feature Stapling

A very interesting concept I came across is Feature Stapling.MSDN explains it as:

In Windows SharePoint Services 2.0, many of the customizations that organizations wanted required changes to the built-in site definitions. These types of customization were not supported by Microsoft because these files may need to be replaced by future service packs. To work around this limitation with the site definitions, you would copy the built-in definitions, make the required customizations, and hide the original definitions from the end user. This process would ensure that a service pack would not break the site definition.
In SharePoint Server 2007, Features enable you to turn functionality on and off within a site, even if the functionality was not in the original site definition. Although modifying the built-in site definitions is still not advisable or supported, you can use a process named Feature Stapling to attach a Feature to a site definition without modifying it in any way. For example, you can use this process to attach your custom application to the built-in definition.

For more refer:
http://msdn.microsoft.com/en-us/library/bb954662.aspx
http://blogs.msdn.com/cjohnson/archive/2006/11/01/feature-stapling-in-wss-v3.aspx

http://blogs.msdn.com/sharepoint/archive/2007/03/22/customizing-moss-2007-my-sites-within-the-enterprise.aspx

Thursday, August 20, 2009

MOSS 2007 : BDC Search

Searching on Business Data once you configure the BDC is easy. Here are a few good links explaining how one could configure search on Business Data and create custom scopes.
http://msdn.microsoft.com/en-us/library/ms584031.aspx
http://msdn.microsoft.com/en-us/library/bb410114.aspx

Wednesday, August 19, 2009

MOSS :Using BDC data in a list

An excellent article that directs in adding bdc data to a list is as below:
http://msdn.microsoft.com/en-us/library/ms548808.aspx

BDC Metadata for SQL Server 2000 Adventure Works db

BDC Metadata for SQL Server 2000 Adventure Works db Here is the metadata for SQL Server 2000 Adv Works DB.I searched a lot for Adv Works 2005 metadata but the msdn samples for 2005 have very elementary stuff in there without filters etc.I needed something a bit more complex and with the tables named product ,customer etc and not dimproduct or dimcustomer.Most sample metadata has the latter tables and I can't find a similar adv works 2000 db. Finally I found this metadata in a msdn link which does work with the current Adv Works Cycles 2000 db.You can download the sample db from the following link: http://www.microsoft.com/downloads/details.aspx?FamilyID=487C9C23-2356-436E-94A8-2BFB66F0ABDC&displaylang=en
The metdata is as in the link below:Note the mode of authentication that worked for me is RevertToSelf.
The only thing you need to add below is your server name as indicated in the tag.
http://msdn.microsoft.com/en-us/library/ms497572.aspx

Hope it works for everyone...working with the BDC is a true test of patience :)

Wednesday, August 12, 2009

SharePoint :Advantages of Data Connection Libraries

The Data Connection Library (DCL) is a new type of document library in Microsoft Office SharePoint Server 2007 that allows applications such as Microsoft Office InfoPath 2007 and technologies like Excel Services to specify data connection settings using external files. This provides several advantages:

  • Reconfiguration: Data connection settings, such as database server locations, can be modified independently of the solutions that use them.

  • Deployment to Different Environments: Test and production servers can specify different locations for data access and a form template will automatically use the server-specific location when published to that server.

  • Authentication: Using Office Single Sign-On, server administrators can specify alternative authentication credentials to be used by the server when processing a form for the browser.

  • Cross-domain security: The Data Connection Library (DCL) serves as a "safelist" for data connections. For forms that are not published with full-trust, only connections specified using the DCL can retrieve data from outside the farm.

Tuesday, August 11, 2009

Sharepoint BDC error:Unable to connect to AdventureWorks,NT AUTHORITY\ANONYMOUS LOGON

I have done a lot of stuff with the BDC in MOSS and everytime I work with it I get a new error ;) I was trying a simple connection to Adventure Works 2005 database which was on a different server.I could connect using the BDC Definition Editor and could retrieve data but when I added a BDC webpart to my SharePoint page , I got "Unable to connect to Adventure Works".It clearly was an authentication issue but I had to track it.Here are the steps I used :
  • I went on to check the SharePoint logs which are stored in:"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Logs" I opened the latest log and searched for "Business Data". There were loads of records.So I thought let me do my own Logging.
  • So I went on to 'Central Administration' -> 'Operations' -> 'Diagnostic Logging' -> 'Event Throttling' and turn on the objects that I wanted to monitor. In this case, I wanted to turn on 'Business Data', select 'None' and 'Verbose'. I also customized my log path so that it was not as long as the default value.
  • Now when I tried connecting the webpart again to my application definition I got the error on my log file "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'"
  • So now I went on and opened my application definition file and changed the authentication type from "PassThough" to "RevertToSelf" authentication and VOILA !! IT WORKED :)


Monday, August 10, 2009

MOSS 2007:List of backup and recovery tools

Here is the list of backup and recovery options to help you decide when and what options you can use:
http://technet.microsoft.com/en-us/library/cc287880.aspx

This article however doesnt mention The SharePoint Designer backup and recovery which is very useful in backing up and restoring almost all levels of MOSS sites(farm,web app,site collectio,subsites) ,mostlysubsites and in also performing backup and restore when one doesnt have direct access to the production server

Thursday, August 6, 2009

Wednesday, August 5, 2009

MOSS Taxonomy and benefits :An excellent article

The following is an article that i found in an excellent blog detailing the beneifts of developing a strong corporate taxonomy as part of a SharePoint 2007 implementation. Hopefully you will find it useful.
Here is the link to the article of which I too have an extract below:

http://joeshepherd.spaces.live.com/Blog/cns!9AE2097A4A610B63!120.entry

The case for a Taxonomy
Understanding the benefits:
Developing a metadata taxonomy is a core step in defining an effective SharePoint 2007 deployment that will be readily accepted by your customer base. This process consists of categorizing the content of your sites and deciding on how users will locate that content. SharePoint offers several key features that make business more flexible and efficient and a solid taxonomy is the foundation that each of these features are built upon. While these features will work without a well formed taxonomy, the existence of even the most simplistic taxonomy can greatly increase their effectiveness. A brief list of features and how they benefit from a taxonomy is detailed below.

  • Content Types
    SharePoint 2007 offers a feature known as a Content Type that can be defined by site and site collection administrators. Content Types are wrappers of MetaData that are created around any set of core content types that exist inside the “out – of – box” SharePoint deployment. These core content types are a Word Document and an InfoPath Form. Administrators can extend these core types and use them to create new custom content types within SharePoint. Administrators specify the MetaData that is associated with the new content type along with any workflows or templates that may be required.
    For example, an administrator can create a custom Content Type of Policy that is based on a word document. That content type could then have certain attributes associated with it such as “Association” that specifies weather this policy applies to a specific department or to the entire organization. Custom workflows could also be attached to this Policy that sends out notifications upon changes to everyone who has an interest in the policy.
    These MetaData attributes provide the greatest functionality if they can be tied back to a larger corporate taxonomy that lays the ground work for defining that MetaData. Content types are a powerful feature in SharePoint 2007 but in order to use them to their potential you must first develop a comprehensive plan on how to categorize your information. Doing so allows you to hone in on those attributes that provide the greatest flexibility and power.
  • Navigation
    Navigation is one benefit of a well thought out taxonomy since it dictates how users navigate the site and its various sub-sites in search of content. Most organizations will opt for a hierarchical taxonomy in this area that closely mimics their organizational structure. This allows for a navigational structure that the user is familiar with.
    For document repositories, such as the document center, navigation based on the taxonomy is important because it allows users to get to the information that they are looking for in a timely manner. If the user is looking for a project request form, the best scenario would be to have that form exist in a Forms library inside the document center. All forms in the organization would exist inside this library that could be further segregated by departments or any other lower level category. A taxonomy will help drive out these requirements up front in the planning stage when changes can me made with little to no cost impact.
  • Search and Indexing
    By effectively leveraging content types that extend a well formed taxonomy, search results can be tailored to specific audiences within SharePoint. This feature will allow administrators to provide targeted search results based upon MetaData attributes for specific users. For instance if a user in accounting performs a search on Policies SharePoint can serve up a subset of that search result that is targeted only to personnel in the accounting department; thus returning only accounting specific policies. The Search mechanism works in tandem with the Content Types to leverage that MetaData derived from the taxonomy.
  • Audience Targeting
    Just as search results can be targeted based on audiences so can content within the individual SharePoint sites themselves. This creates the ability to intermingle content in the accounting site and specify that that content only be visible to individuals in the accounting department. This provides an abstract layer of security at the site level that would otherwise have to be configured via roles and access permissions. Once again this capability is largely driven off the effective use of Content Types and those MetaData attributes.
  • Information Categorization and Retrieval
    Just as you would organize the documents in your filing cabinet so should you take the time to develop a consistent classification system for the content of your SharePoint sites. Going through the work of establishing a solid taxonomy and MetaData system now will allow you to organize your information into categories that afford users the ability to rapidly locate any information or content they need. The taxonomy helps to ensure that everyone thinks about each item of content the same way. It provides a consistent way of classifying and describing content and information. It also allows you to ensure that the content is stored on the correct place, it is made available to the correct people and that it is managed in a manner that is consistent with that type of content.

Tuesday, August 4, 2009

Debugging custom SharePoint applications

I got an excellent article which outlines common debugging issues and their solutions.Here it goes:

First thing you need to do to avoid the old fashioned trial and error technique is to enable debugging. This could be achieved by setting the compilation element debug attribute to true in Web.Config from the virtual directory containing your SharePoint application, otherwise, breakpoints inside Visual Studio will be shown but will never be used.
Once you’ve done that, there is one more thing you need to do in order to be able to debug your SharePoint code in Visual studio which is attaching a debugger to W3WP.EXE, Attaching a debugger in Visual Studio will allow you to step through the code and find exactly where the error occurs.




























It’s really handy but there are three questions that I always receive from my colleagues when they get started to SharePoint programming, so I decided to share the answers with you.
The first one is: Sometimes, I set breakpoints and attach to the process but Visual Studio skips loading the symbols if I’m debugging a deployed assembly to the GAC and I fail to debug the code
Easy, Open Tools -> Options -> Debugging.
You’ll find an option labeled Enable Just My Code (Managed Only) as shown in the figure which is checked by default. Uncheck this option to be able to debug the assemblies located in the GAC.

There is a common myth among .NET developers in general and especially SharePoint ones, that in order to debug assemblies that have been deployed to the GAC, you need to copy the debug symbols (PDB File) to the GAC as well. This was true in the early days of .NET but this is no longer true. The second one is: When I try to attach the debugger to the W3WP.exe process to debug, I always see multiple instances of it. Which one should I attach to?
Ok, this is easy too. Just follow the following steps.
Open the command prompt window, run IISAPP to get a list of the current instances of W3WP.exe.

Note the PID of the instance that corresponds to your web application.

Now return to VS, select Debug -> Attach to process and attach to the W3wp.exe instance with an ID equivalent to the PID you got in step 2 -> click Attach.
Now you can trace through the code and find the error causes easily.
But the question still remains, why sometimes are they more than one w3wp.exe instance? This is because the SharePoint Administration Site Collection and the SSP Administration site always have their own Application pools for error isolation purposes.

And the third question is : Is it possible to debug Inline code blocks ?
Actually, I hate Inline Code Blocks and it’s really a good practice to avoid it due to the performance issues when the JIT compiler compiles them but YES, you can do that.
So now you knew the process of debugging? Very boring and repetitive huh? Hmm, Can’t that be automated?Fortunately Jonathan Dibble, a brilliant developer, created a very handy “
Debugger Feature” that can be installed and activated on a SharePoint site to automate this process. Once activated, the Debugger Feature adds an “Attach Debugger” menu item to the Site Actions menu. Extremely helpful and faster than doing that from visual studio.

To read the complete article go on to:http://sharepointmagazine.net/technical/development/getting-started-with-sharepoint-programming-simplifying-sharepoint-debugging-by-creating-the-troubleshooting-toolbox

Happy Debugging :)





Monday, August 3, 2009

How to write to Event Log using visual C#

Write to an event log
Event logging provides a standard, centralized way for your applications to record important software and hardware events. Windows supplies a standard user interface for viewing the logs, the Event Viewer. By using the common language's run-time EventLog component, you can connect to existing event logs easily, on both local and remote computers, and write entries to these logs. You can also read entries from existing logs and create your own custom event logs. In its simplest form, writing to an event log involves only a few steps to create a sample application. To do this, follow these steps:
  • Open Visual Studio C#.
  • Create a new Console application in Visual C#.
  • The Console application creates a public class and an empty Main method for you.
  • Verify that the project references at least the System.dll file.
  • Use the using directive on the System and System.Diagnostics namespaces so that you do not have to qualify declarations from these namespaces later in your code.

You must use these statements before any other declarations.

using System;

using System.Diagnostics;
To write to an event log, you must have several pieces of information:

Your message, the name of the log you to which you want to write (which will be created if it does not already exist), and a string that represents the source of the event.

You can register a particular source with only a single event log; if you want to write messages to more than one log, you must define multiple sources.

string sSource;

string sLog;

string sEvent;

sSource = "dotNET Sample App";

sLog = "Application";

sEvent = "Sample Event";
Use two static methods of the EventLog class to check whether your source exists, and then, if the source does not exist, to create this source that is associated with a particular event log.

If the log name that you specify does not exist, the name is created automatically when you write your first entry to the log.

By default, if you do not supply a log name to the CreateEventSource method, the log file is named "Application Log."

if (!EventLog.SourceExists(sSource))EventLog.CreateEventSource(sSource,sLog);


To write a message to an event log, you can use the EventLog.WriteEntry static method.

This method has several different overloaded versions.

The following sample code shows the simplest method, which takes a source string and your message, and one of the more complex methods, which supports specifying the event ID and event type:

EventLog.WriteEntry(sSource,sEvent);

EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
Save your application.

Run your application, and then check the Application log in the Event Viewer to see your new events.

Complete code

using System;

using System.Diagnostics;

namespace WriteToAnEventLog_csharp

{

/// Summary description for Class1.class

Class1{static void Main(string[] args)

{

string sSource;

string sLog;

string sEvent;

sSource = "dotNET Sample App";

sLog = "Application";

sEvent = "Sample Event";

if (!EventLog.SourceExists(sSource))

EventLog.CreateEventSource(sSource,sLog);EventLog.WriteEntry(sSource,sEvent);

EventLog.WriteEntry(sSource, sEvent,EventLogEntryType.Warning, 234);}}}

MOSS 2007 ebooks