Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Archive for August, 2012

SharePoint 2010 Document ID Feature

Posted by JP on August 30, 2012

In this article we can explore the Document ID feature and how to programmatically retrieve documents based on the IDs.

Scenario

Your customers are using Document Libraries for creating, updating and sharing documents. A problem could arise when the same document could exist in multiple libraries with the same name. There should be a way to identify the document using some Unique ID so that the document could be managed effectively independent of the location.

Document copy 1

image

Document copy 2

image

Solution

SharePoint already contains the Document ID service feature which could be used to address this problem. Document ID Service is a Content Management feature and explicit activation is needed in the site collection level. Once activated all the documents in the site collection will be assigned a unique ID.

Note: The Document ID is different from Record ID. Additionally List items cannot be assigned Document ID.


How to enable Document ID Service?

You have to go to the Site Collection Top Level Site and choose Site Actions > Site Settings > Site collection features.

image

In the appearing page Activate the Document ID Service feature.

image

On activating the feature a Timer Job will be assigned to generate Document ID for all the existing documents.

You can make the Timer Job run immediately by going into Central Administration > Monitoring > Check Job Status > Scheduled Jobs link.

image

Click on the Job named Document ID assignment job and in the appearing page click on the Run Now button. This should create Document ID for all the documents in site collection libraries.


Document ID Settings

Once the feature is activated you can change the settings through Document ID Settings link as shown below. This link is only visible once you enable Document ID Service feature.

image

In the appearing page you can change the Settings like Prefix for generating ids for example: COM-DOC-1, COM-DOC-2 etc. You can assign a prefix of 4 to 12 characters.

image

Click the OK button to continue. You need to run the Timer Job again to see the immediate assignment of IDs.


Viewing the Document ID

Once the Document ID is assigned you can go back to any library in the Site Collection and use the View Properties menu item to view the ID associated.

image

In the appearing dialog the Document ID is shown.

image

Note: Copying documents will create new Document ID for the new document. Moving document will retain the original Document ID.


Using Document ID Programmatically

Now we can use Server Object Model to get a document using the Document ID. Please follow the following steps to achieve the same:

Step 1: Create a new SharePoint 2010 > Console Application

image

Step 2: Add reference to Microsoft.Office.DocumentManagement assembly

This assembly should be residing in the 14hive\ISAPI folder. You can use the Add Reference dialog box > SharePoint tab for locating the same.

image


Step 3: Create the code to fetch by Document ID

You have to use a DocumentIdProvider instance to perform the same. The following code fetches the Document Url based on the Document Id.

static void Main(string[] args)

{

SPSite site = new SPSite("http://localhost/sites/newsitecollection");

DocumentIdProvider provider = DocumentId.GetProvider(site); ;

var result = provider.GetDocumentUrlsById(site, "DOCUMENT-4-1");

Console.WriteLine(result[0]);

Console.ReadKey(false);

}

You need to change the Site Url and Document ID string according to yours. On running the code the url of the Document is shown.

image

With the document url in hand you can write your own code to manipulate it.

Note: You can also use the DocumentId.FindUrlById() method to retrieve the url as a string.


References

http://tinyurl.com/7s9ffby

Summary

In this article we have explored the Document ID feature and retrieving documents based on the Unique ID.

Following are the points to summarize with:

  • · Document ID Service is a Content Management Feature
  • · A Site Collection Level Feature
  • · Once activated all documents are assigned unique IDs
  • · Programmatically we can retrieve document by ID
  • · Prefix can be used along with the Document ID
  • · A Timer Job is responsible for assigning the IDs
Advertisements

Posted in SharePoint | Tagged: , | Leave a Comment »

Finding an Orphaned Workflow & Cancelling it

Posted by JP on August 29, 2012

Last week I encountered a weird problem like below:

  • A task email was being sent to the user
  • The document associated with the task is already deleted
  • SharePoint keeps sending task overdue emails
  • How to cancel the workflow?

The task email looks like “Task created on 04/01/2012 is overdue”

How to resolve this problem?

I would recommend the following solutions:

  • Use the workflow.aspx to locate and terminate the workflow

If not possible due to page corrupted or task is deleted:

  • Use wfterminator.codeplex.com to terminate the workflow

If not possible due to SharePoint 2007:

  • Install the latest cumulative update pack which should have fixed the problem.

If not possible due to deployment hassles or problem being repeated:

  • Use Server Object Model to create a program to find list by ID and delete workflow associated

If not possible due to invalid list id / list not retrievable for deleted status

  • Contact Microsoft Support if you have a paid support privilege

If not possible as you do not have paid support

  • Find the workflow instance from content database & change the columns InternalState & Status1 to 8

About manually updating the Database

Now you are reading something which Microsoft does not recommend.  I repeat usage of Server Object Model is  the best way.  But as you failed all the above steps and your customer is yelling then you have to proceed this difficult path.  Use this option when there are no customers online, recommend a restart of IIS application for WFE after this.

Step 1: Locate the ListId from AllDocs table

The AllDocs table contains a column LeafName which should be matching your document name for eg: info.doc.  Take the corresponding ListID value from there, which is actually a GUID.

eg: SELECT * FROM AllDocs WHERE LeafName=’info.doc’

Step 2: Go to the Workflow table to find instances

Use the ListId to fetch Workflow instance matching it: SELECT * FROM Workflow WHERE ListId=’GUID’

Step 3: Find the culprit record

Locate the right record using InternalState and Status1 column which should be equal to 2 stating Running.

You should be able to filter further using the Created column representing the task creation date. (it should be matching the customer email)

For your reference please find the SPWorkflowState enumeration.

image

Step 4: Fix the record

Change the InternalState & Status1 columns to 8 (For Canceledl).

Make sure you are changing only 1 record for 1 email problem.

Step 5: Restart WFE

Restart the WFE (not required exactly as workflow is executed by timer job) and inform the customer.  He/she should not receive the email  once after that.

Good Luck – and do not say my name Smile

Posted in SharePoint | Tagged: , | Leave a Comment »

WF Terminator

Posted by JP on August 25, 2012

Logo

WF Terminator is a SharePoint 2010 Tool to Examine and Terminate Workflows.

Requirement

Following is the scenario upon which I have created the tool:

· Customer needs to terminate a workflow instance

· Administrator needs a better tool to filter, examine & terminate workflows

SharePoint 2010 user interface provides a Workflow page to perform the same. But in case if the Administrator credentials not available the above tool can be used to filter, examine & terminate the running workflows. By default the System Account user token is used to impersonate to the site.

Advantages

The tool provides the following features:

· Enumerating the workflows using System Account

· Filtering the results based on Workflow Status, Workflow User Name etc.

· Termination of Workflow

Download

The tool is available in codeplex.com. The main page is given below:

https://wfterminator.codeplex.com/

Use the Download link as shown below:

clip_image002

Screen Shot

Following is the screen shot of WF Terminator:

clip_image004

How to use it?

1. Download and execute the file.

2. Enter the site url

3. Enter your credentials, leave as blank for using System Account

4. Click on the Find Workflows button

5. Filter the result further using the Internal Status drop down list

6. Filter the result further using Author User text box

7. From the result, select a workflow to see the properties in grid

8. Click the Terminate button to cancel the workflow after ensuring

9. Confirm the Termination and the workflow will get stopped

10. Close the Application

Filtering

Two levels of Filtering are provided:

1. Workflow Internal State (Locked, Running, Completed, Cancelled etc.)

2. Workflow Author Name (eg: domain\user1, domain etc.)

Summary

In this article we have explored the WF Terminator tool and the possible advantages of using it. The tool could be useful in the scenarios mentioned above.

As always I am open to hear from you. You can give feedback on improvement areas and feature requests.

Posted in SharePoint | Tagged: , , , | Leave a Comment »

Delete an Orphaned Workflow

Posted by JP on August 24, 2012

In this article we can explore a real world scenario where a workflow is sending reminder email to users and the interesting thing is that the task list & data no long exists.

I have encountered such scenarios multiple times in my consulting arena and I would recommend running the latest cumulative updates to resolve the issue. In cases where the update patching is not feasible you can use the following solution approach.

Understanding the Problem

To make sure the problem is being conveyed correctly I am using the following points:

1. Task List named Approval List was created

2. A new item was added to the Task List

3. An Approver is being notified on the task

4. The Task List was deleted, removed from Recycle Bin too

5. The notification mail is being sent every week

6. The user cannot modify the task or approve it to stop the emails

This case can arise due to an incomplete migration where the relational columns are mismatched. Our focus is to fix the problem so that our user is not being disturbed by obsolete or invalid emails.


Examining the Problem

As the first step you can try to impersonate as the user into the SharePoint web application. If you cannot access the user credentials you can try examining the SharePoint content database. The content database contains the list, list records, user, work flow information for a SharePoint web application.

You can get the content database name of the web application from Central Administration.

clip_image001

You can see the content database name from the appearing page. Ensure that you are referring to the right web application.

clip_image003

You can click on the Database Name link to see more information about like Server Name.

clip_image005

Now you can try logging in to the database using SQL Server Management. Following are our tables of interest. (Here we are examining List Workflows)

Table

Description

AllLists

This table contains the list metadata like Title, Description etc.

AllUserData

This table contains the user data like list item.

Workflow

This table contains the workflow instances.

Please note that there are no referential constraints but GUID values are used to interconnect between tables. Following are the table structures:

clip_image007

Note: Modification to the table using SQL / Direct Editing is restricted by Microsoft. You should use the Server Object Model for any modifications.

Proposed Solution

The advisable solution is to terminate the workflow using the SharePoint user interface.

To achieve this open Lists > Site Workflows link.

clip_image009

Click on the highlighted link as shown above. You should get the following Workflow Information page.

clip_image011

Click on the Terminate this workflow now link as shown above.

If the workflow gets terminated then you are good. Your customer should be happy as he will be free from the wrong email alert.

You can verify the database record to ensure the InternalStatus column is set to 8.

clip_image012

The enumeration for Internal State column mapping to SPWorkflowState is given below:

clip_image014

Extended Proposed Solution

This solution involves much more effort and advisable if the User or Administrator is not able to perform the above. You can write a piece of code to fetch the workflows under running state and cancel it using the Server Object Model.

Step 1: Create a new windows application

Create a new windows application and make the .Net version to 3.5, Platform Target to Any CPU. Add 1 TextBox, 2 Button and 1 ListBox as shown below:

clip_image016

Step 2: List the Workflow Instances

On the Find Running Workflow button click event invoke the following method which list all the Workflow Instances.

private void RefreshList()

{

using (SPSite site = new SPSite(UrlText.Text))

{

using (SPWeb web = site.OpenWeb())

{

List.Items.Clear();

_internalList = new List<SPWorkflow>();

foreach (SPWorkflow workflow in web.Workflows)

{

List.Items.Add(workflow.AuthorUser.LoginName + " " + workflow.InternalState.ToString() + " " + workflow.Created.ToShortDateString() + " " + workflow.StatusUrl);

_internalList.Add(workflow);

}

}

}

}

private IList<SPWorkflow> _internalList;

Note: Please note that periodically Workflow table is cleared of the completed workflows by a Timer Job.

Step 3: Terminate the Workflow

For terminating the Workflow use the following code.

private void TerminateButton_Click(object sender, EventArgs e)

{

if (List.SelectedIndex >= 0)

{

if (MessageBox.Show("Are you sure to Terminate this Workflow?", "Confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)

{

SPWorkflow workflow = _internalList[List.SelectedIndex];

SPWorkflowManager.CancelWorkflow(workflow);

RefreshList();

MessageBox.Show("Terminated.. The list will be refreshed after Timer Job removes the workflow entry!");

}

}

}

Note: Here we are using SPWorkflowManager class to terminate the workflow. The CancelWorkflow() is the method used to perform the same. After cancelling the item will be removed by a timer job.

Step 4: Execute the Application

On executing the application you can see all the workflows listed. Selecting the appropriate workflow and clicking the Terminate button should make the Workflow Internal State to Cancelled. From this point onwards the obsolete email problem will be stopped.

clip_image018

Note: Currently the workflow author, date and url information are added in the list. You are free to add additional information about the workflow in the list.

References

http://tinyurl.com/sp2010-wf-terminate

Summary

In this article we have explored a possible problem associated with obsolete task emails workflow and the solutions for it.

I would like to iterate that Microsoft recommended way of solution is to use the Server Object Model or Client Object Model to make the database changes rather than using SQL statements directly on the content database.

The source code for the article is attached.

Posted in SharePoint | Tagged: , , , | Leave a Comment »

Terminate a Workflow manually

Posted by JP on August 22, 2012

In this article we can explore the steps needed to terminate a workflow manually. A SharePoint might need this step if they encountered the following:

· Task overdue email workflow for non-existing task

· Approval workflow unwanted triggers

Solution

Please follow the following steps to terminate an unwanted workflow.

Step 1: Open the SharePoint site and click the Lists link

clip_image001

Step2: Click on the Site Workflows link

In the appearing page click on the Site Workflows link as shown below.

clip_image002

Step 3: Find the Workflow

You can see the My Running Workflows and for each workflow there is a status on the right side. Click on the In Progress link as highlighted below.

clip_image004

Step 4: Terminate the Workflow

On receiving the following page click on the Terminate this workflow now link

clip_image006

Step 5: Conclusion

This concludes our steps in terminating an unwanted workflow. You can use the same steps for MOSS 2007 and SharePoint 2010 as well.

Note: If you are an Administrator you can Terminate the workflows of other users as well.

References

http://tinyurl.com/sp2010-wf-trm

Summary

In this article we have seen how to terminate a running workflow. This article content could be shared with the user as well if they face the same problem.

Posted in SharePoint | Tagged: , , , , | Leave a Comment »

SharePoint 2010 – Cumulative Updates Information

Posted by JP on August 22, 2012

In this chapter we can learn about Cumulative Updates. Cumulative Updates are important while developing & deploying SharePoint solutions.

What are Cumulative Updates?

Microsoft periodically releases software updates for Microsoft SharePoint Server 2010 and Microsoft SharePoint Foundation 2010. It is important to understand what these updates are and how to deploy them to servers or server farms.

In short Cumulative Update contains:

· Hotfixes since the release

· Support Issues being addressed since release

It is recommended that you install the latest update to ensure the full functionality of SharePoint with hotfixes. The update file will be having extension msp. Depending on your SharePoint edition (Foundation, Standard, Enterprise) choose the Foundation or Server version of update.

Which is the right version of Update?

As time goes by new updates are released by Microsoft. You have to download and install the latest version of update.

The latest version can be downloaded from the following location:

http://tinyurl.com/sp2010-cu

The link should take you to the Technet site of Microsoft.

clip_image002

Downloading the Update

Scrolling down in the above page you can see the Update releases as shown below:

clip_image003

Click on the KB link to download the appropriate package. It will lead you to the next page where the update information is available. You can get information on what are the fixes and scenario included in the update.

clip_image005

Click on the Hotfix Download Available button to continue to get the following page.

clip_image007

Enter your details and on submitting, the update will be emailed to you within few seconds.


How to find the Patch Information of your SharePoint?

In the case of SharePoint 2007:

· Site Actions > Site Settings revealed the version information

For SharePoint 2010 you can use Central Administration web application for the purpose:

· Central Administration > Upgrade and Migration > Check product and patch..

clip_image009

On clicking the above link you can see the patch information as shown below:

clip_image011

The top row shows the latest Version installed.


References

http://tinyurl.com/sp2010-cui

http://tinyurl.com/sp2010-cu-learn

Summary

In this article we have gone through the Cumulative Update information on SharePoint 2010. In the real world scenarios, installing latest Cumulative Update should save much of development & debugging time.

Posted in SharePoint | Tagged: , , , | Leave a Comment »

Global Event Receiver to Block Malicious Files

Posted by JP on August 20, 2012

In this article we can explore the scenario to block malicious files by content.

Scenario

Your customer reported a specific feature on All the document libraries in a site.  The document libraries should accept uploading of Executable files (.exe) plus a virus check has to be done on the content.  If the exe files are infected then the upload should be aborted.

Solution

In this case you can create a Global Event Handler for all the document libraries.  This event handler is invoked whenever a file is being uploaded.  A virus check can be performed based on the Antivirus software installed.  The upload can be aborted using the Cancel property in the event handler method.

Implementation

Following are the steps involved in implementing the solution:

·         Manage the Blocked File Types

·         Test an exe file insertion into Library

·         Create the Event Receiver

·         Make the Event Receiver Global

·         Test the Application

Manage the Blocked File Types

As you might have noticed the executable extension (.exe) is blocked in all SharePoint libraries.  This restriction can be removed by using Central Administration.

In our case we need to allow this extension (.exe) and later our own event handler will do the file scanning for adding to the library.

To change the restriction open Central Administration > Security link.

clip_image002

In the appearing page click on the Define blocked file types link as shown below:

clip_image004

In the appearing page you can see that there are lots of extensions being blocked.  Remove the exe entry from the list and click the OK button.

clip_image006


 

Test an exe file insertion into Library

After making the change (removing exe extension) you can try inserting an exe file into a document library.  For the time being I tested inserting Calculator (c:\windows\system32\calc.exe) into my library.

Now I was able to successfully insert an exe file into the library.

clip_image008

Note: Please make sure that you selected the right web application from the right top menu.

Create the Event Receiver

Our job is not finished yet.  The current situation may create a Security Threat of malicious exe files being uploaded by users unknowingly.  Later other users may execute it and create chaos.  So we need to ensure that the content of the Executable file is not having any malicious code inside it.

The actual way of scanning the exe file is to integrate some third party Anti-Virus SDK with our application.  As this exceeds our scope of the article I prefer checking the exe file name containing any special characters like !, @, #.   If any of the characters found the file will be cancelled from insertion and a message will be shown to the user.

Now let us create the event handler which blocks the file if file name contains special characters.


 

Create a new project of type Event Receiver inside Visual Studio 2010.  Name the project as GlobalEventReceiver.

clip_image010

Choose the site for the project and In the Event Receiver Settings dialog select the options like Document library and Add, Update events as shown below:

clip_image012 

Click the Finish button to continue.


 

In the appearing event file replace the Item Adding event as following:

public class EventReceiver1 : SPItemEventReceiver

{

    public override void ItemAdding(SPItemEventProperties properties)

    {

        if (properties.List is SPDocumentLibrary)

        {

            if (properties.AfterProperties != null)

            {

                if (properties.AfterProperties["vti_filesize"] != null)

                {

                    if (properties.AfterUrl != null)

                    {

                        if (properties.AfterUrl.Contains("!") || properties.AfterUrl.Contains("@") || properties.AfterUrl.Contains("#"))

                        {

                            properties.Cancel = true;

                            properties.ErrorMessage = "Potential malicious content in file!";

                        }

                    }

                }

            }

        }

    }

 }

The event is invoked with the SPItemEventProperties server object model which contains the document, url and related properties.  As we are making this event Global, all the lists and libraries will be invoking this event handler.

To prevent the event being blocked in Lists/Folders we are ensuring the properties.List is of type Document Library in the first if block.

In the second and third if blocks we are ensuring the file size is not null.

In the fourth and fifth if blocks we are ensuring the file url does not contains the special characters like !, @, #.  (our dummy malicious check)

If the malicious check resulted in true, then the Cancel property is set to true, which will prevent the file being inserted.  An Error Message is set for the user.


 

Make the Event Receiver Global

The current event receiver is hard coded for document template Id 101.  We need to make this global so that all the document libraries will be attached to this event.

Open the Elements.xml from the EventReceiver1 folder.

clip_image013

Remove the  ListTemplatId=”101” attribute from the Receivers tag (third line) as below:

<?xml version="1.0" encoding="utf-8"?>

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Receivers>

      <Receiver>

        <Name>EventReceiver1ItemAdding</Name>

        <Type>ItemAdding</Type>

        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>

        <Class>GlobalEventReceiver.EventReceiver1.EventReceiver1</Class>

        <SequenceNumber>10000</SequenceNumber>

      </Receiver>

      <Receiver>

        <Name>EventReceiver1ItemUpdating</Name>

        <Type>ItemUpdating</Type>

        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>

        <Class>GlobalEventReceiver.EventReceiver1.EventReceiver1</Class>

        <SequenceNumber>10000</SequenceNumber>

      </Receiver>

  </Receivers>

</Elements>

 

Now build the application.

Test the Application

Execute the application and in the launched SharePoint site, open a document library and try to add an exe file with a “@” character in the file name.

For example: calc@renamed.exe

You should get the following error:

clip_image015

So this confirms the Global Event Handler at work.

Note: The Item Add event handler is needed to handle document insert event.  The Item Update event handler is needed to handle the document update event.Note: The scenario explained above is for conditional blocking purpose and in the real world the same Global Event Handler mechanism can be used to handle other situations like:

·         Prevent PDF file insertion on Document Libraries

·         Disable Copy Paste between different document library types

·         Disable file insertion based on validation etc.

References

In this article we have explored the problems with updating multiple web configuration file

Summary

In this article we have explored the problems with updating multiple web configuration file and the usage of SPWebConfigModification model to resolve it.  In real world scenarios this model should give an advantage edge for the developer and it is the recommended way for doing configuration modification.  The attachment contains the sample application we have discussed.

Posted in SharePoint | Tagged: , , , , , | Leave a Comment »

Disable Delete option of List

Posted by JP on August 19, 2012

In this article we can explore how to protect a list from getting deleted by the user. In real world scenarios there are chances that the user can use the List Settings > Delete list option.

clip_image001

We have to make sure that the above option is hidden for the user through SharePoint user interface.

There are multiple ways to achieve this:

· Use Visual Studio to make the list property AllowDeletion to false

· Use PowerShell to make the list property AllowDeletion to false

· Create a new Permission with Delete Restriction on List and assign to the user

Here we are using the Visual Studio and PowerShell approach to disable the Delete option.

Visual Studio Approach

Create a new list in your SharePoint site and name the list as New List. Ensure that through the List Settings page you can see the Delete this list link.

clip_image003

Now create a new console application inside Visual Studio and name it as AllowDeletionFalse.

clip_image005

Inside the code modify the Main method as shown below:

static void Main(string[] args)

{

SPSite site = new SPSite("http://localhost&quot;);

SPWeb web = site.OpenWeb();

SPList list = web.Lists["New List"];

list.AllowDeletion = false;

list.Update();

}

The code above connects to the url specified, gets the instance of the list named New List and modifies the property AllowDeletion to false.

Build and execute the application. If it executed without errors the list is now having the Delete link hidden. You can verify this by going back to the List Settings page inside SharePoint.

clip_image006

From the Permissions and Management group you can see that the Delete this list link is missing. This makes our list protected from unwanted delete activity by a user.

PowerShell Approach

Now we can try to reverse the AllowDeletion property using PowerShell script. Please note that for these type of scenarios on client locations PowerShell would be more handy. (Visual Studio might not be installed in the customer premises)

You can start the PowerShell Editor aka ISE (Integrated Script Editor) from Start > Programs > Accessories > Windows Power Shell menu group.

clip_image008

The editor is shown below. Save the default file as AllowDeletionFalse.ps1. (ps1 is the extension for PowerShell scripts)

clip_image010

Following is the shown above in the .ps1 file.

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )

{

Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell

}

$web = Get-SPWeb -Identity "http://localhost&quot; -AssignmentCollection $assignment

$list = $web.lists["New List"]

$list.AllowDeletion = $true

$list.Update()

Code Explained

The first If block make sure that the Microsoft.SharePoint.PowerShell snap in is loaded in to memory. (It is similar to add reference in Visual Studio)

The Get-SPWeb cmdlet retrieves the reference to specified web application. The web.lists returns the reference to our New List. After setting the AllowDeletion to true the list is updated. You can use the Run command of the PowerShell editor to execute the code.

clip_image011

Once the code executed successfully our New List should have the Delete this list link visible in the List Settings. You can refresh the List Settings page to ensure that it is restored.

clip_image012

References

http://tinyurl.com/sp2010-list-allow-del

Summary

In this article we have seen how to protect a list by disabling the Delete list option using Visual Studio and PowerShell. The source code is contained in the attachment.

Posted in SharePoint | Tagged: , , , , | Leave a Comment »

SharePoint 2010 Built-in Web Parts

Posted by JP on August 18, 2012

In this article we can explore the following inbuilt Web Parts inside SharePoint 2010.  The site collection used here is having Team Site template.

·         Announcements

·         Links

·         Team Discussion

·         Content Editor

·         Relevant Documents

·         Note Board

·         Organization Browser

·         Site Users

Testing the Web Parts

You can create a new Site Page for testing the Web Parts.

image

After creating the page use the Edit Page option and from the Insert tab click on the Web Part button.

image

After inserting the specified web part you can use the Save & Close button from the Page tab to save changes.

image

Announcements Web Part

We can start playing with the Announcements Web Part.

Purpose:  This web part can be used to track upcoming events, status updates or other team news.

Group: Lists and Libraries

image

In Action

Following is the saved page after inserting the web part.

image

Note: From this group you can add any existing list or library.  This is a more convenient way of showing multiple lists in a page.  If you cannot see an Announcements from the above group, go to the Lists and create a new list using template Announcements.


 

Links Web Part

Purpose:  This web part can be used for creating links to Web pages that your team members will find interesting or useful.

image

In Action

Following is the saved page after inserting the web part.

image

Team Discussion Web Part

Purpose:  This web part can be used to list to hold newsgroup-style discussions on topics relevant to your team.

image

In Action

Following is the saved page after inserting the web part.

image

Content Editor Web Part

Purpose:  This web part can be used to use rich content.  So this web part helps in adding formatted text, tables, hyperlinks, and images to a Web Part Page

image

In Action

Following is the saved page after inserting the web part.

image

For adding formatted text you can use the Edit Page option and the Format Text tab is visible like below:

image

Note: You can include JavaScript code in this web part and thus provides higher control over the entire page if required.


 

Playing around more with Content Editor Web Part

Now let us try to do more with the Content Editor Web Part.  Our aim is to call a JavaScript method from inside the Content Editor Web Part. (in turn it is calling Java Script from SharePoint)

Following are the steps involved:

1.       Create a new Java Script file

2.       Upload it to the Site Assets library

3.       Add a Content Web Part

4.       Modify the HTML Source

5.       Play the action

Create a new file and name it as JavaScript.js (attached).  Insert  the following contents inside it.

alert(‘A message from Java Script inside SharePoint 2010.. How is that?’);

Add the file into the Site Assets library in SharePoint.  Site Assets is a pre-created folder in the site which is used to store CSS, JavaScript and other site asset files.  You can find it over Libraries > Site Assets.

image 


 

Now add a new Content Editor Web Part and click on the Format Text tab > HTML button > Edit HTML Source link.

image

Add the following code in the appearing dialog box:

<script src="../SiteAssets/JavaScript.js" type="text/javascript"></script>​​​​​​

Now click OK to the dialog, go to the page click the Save button and refresh the page.  You should see the following dialog box from Java Script.

image

 

Note: Please note that the SiteAssets folder name is referred without spaces.

Relevant Documents Web Part

Purpose:  This web part shows the documents that are relevant to the current user.  Basically it will be remembering the documents the current user had dealt with and provides a convenient piece of feature.

image

In Action

Following is the saved page after inserting the web part.

image

Note Board Web Part

Purpose:  This web part can be used to enable users to leave short, publicly-viewable notes about this page.  Adding on the home page it helps in notifying all users on active events / messages.

image

In Action

Following is the saved page after inserting the web part.

image

Organization Browser Web Part

Purpose:  This web part displays each person in the reporting chain in an interactive view optimized for browsing organization charts.

image

In Action

Following is the saved page after inserting the web part.

image

Site Users Web Part

Purpose:  This web part can be used to to see a list of the site users and their online status.

image

In Action

Following is the saved page after inserting the web part.

image

References

            http://tinyurl.com/sp2010-customwebpart

http://tinyurl.com/sp2010-cntedt

http://tinyurl.com/sp2010-wpjs

Summary

In this article we have explored the Built-in WebParts in SharePoint 2010.  I believe the knowledge will give you good decision edge while developing SharePoint solutions.

Posted in SharePoint | Tagged: , , , , | Leave a Comment »

SharePoint 2010 – Create SSL enabled Site

Posted by JP on August 15, 2012

As part of development activities we might need to create SSL enabled site inside SharePoint 2010. These sites will be accessed using https instead of http.

For example:

clip_image001

HTTPS is the secured way of communication between server and client. Here the message is encrypted between client and server. An encryption mechanism is needed protect the message from being manipulated by unwanted parties.

HTTPS works by installing a certificate in the server side web application. This certificate is used to encrypt the messages between client and server. The encryption is based on a public key and private key usage. The public key will be shared with client for encrypting the message and the decryption is performed on the server side using the private key.

Note: Stealing the public key does not do any favour in decrypting the message using Man In the Middle attack as Public key can only be used for encryption.

Please following the steps given below to create a new SSL enabled SharePoint site.

Step 1: Create New Web Application

Go to Central Administration and open the Manage Web Applications link. Create a new Web Application with the following properties:

1. Name as My Secured Site

2. Use Secured Sockets Layer (SSL) Yes

clip_image003

clip_image004

Click the OK button to create the new web application.

Now add a new site collection inside the newly created web application.

Central Administration > Create Sitecollection > Choose current web application

Step 2: Set the Certificate

For SSL enabling you need to specify a Certificate in the Server which contains the public and private keys. Go to Internet Information Services (IIS / inetmgr.exe) and select the newly created site. Click on the Bindings link from the right side.

clip_image006

In the appearing dialog select the https item and click the Edit button.

clip_image007

In the appearing dialog select the Certificate from drop down list.

clip_image008

Click the OK button to continue.


Step 3: Test the url

Now you are ready to test the HTTPS url. Open a browser and enter the url of the web site. You can also you the Browse link from IIS.

You will get the page as shown below. It says the certificate is not trusted one. You can use the Continue link to proceed with.

clip_image010

Now you should be prompted with the site credentials. Enter the credentials to continue and you should get the site collection which you have created.

clip_image012

Wow! If you can see the above site then you are done with your SSL enabled site. Please note that the url now starts with https

Adding SSL (https) support to an existing web application

You can add SSL support to an existing web application by performing the following:

1. Open IIS manager

2. Select the web application

3. Choose Bindings dialog

4. Add new binding of type https

5. Select the Certificate

6. Click the OK button

References

MSDN on SharePoint SSL

SSL, Public Key, Private Key

Summary

In this article we have seen how to enable SSL on a SharePoint site. I hope you were able to create a successful SSL enable SharePoint site.

Posted in SharePoint | Tagged: , , , | 2 Comments »