Difference between Security Context of Workflow Code in SharePoint 2007 and 2010

By namwar - Last updated: Wednesday, May 16, 2012

In SharePoint 2010, any code which executes because of the changes made by the workflow process will run in context of the user who either started the workflow or responsible for changes which caused the code to be executed.

But …

In SharePoint 2007,  any code which executes because of the changes made by the workflow process will always run in context of SharePoint\System.

Due to the above difference, your SharePoint 2007 code will be able to perform anything on your Site as it will always have Full Permissions whereas in SharePoint 2010, it will depend on the user permission. If you are porting your code from 2007 to 2010 and will need full permission then you should consider using SPSecurity.RunWithElevatedPrivileges method. For details on it, click here

Share
Filed in Architecture, Code, Information, Security, SP2010, Tips, Tools, Troubleshooting, Workflow • Tags: , , , , , , ,

Ideal list of tools you need for SharePoint Development

By namwar - Last updated: Monday, May 7, 2012

After working with several clients, I have compiled a list of tools, addons, plugins and technologies which are needed for development, customization or administration of SharePoint. This list is not a “Mandatory Tools List” but in fact, it is a compilation of tools and technologies which can be used at any point in time depending on your role. I will keep extending this list.

Please feel free to suggest more:

Infrastructure

  1. VMWare Workstation
  2. Windows 2008 R2
  3. SQL Server 2008
  4. Team Foundation Server 2010

Development

  1. Visual Studio 2010 Professional / Ultimate / Premium
  2. SharePoint Designer 2010
  3. Visio 2010
  4. Infopath 2010
  5. Fiddler
  6. Nintex Workflow
  7. K2 Workflow
  8. AgilePoint Workflow
  9. Bamboo WebParts
  10. Microsoft Expression Studio
  11. Telerik Controls
  12. Infragistics Controls
  13. SharePoint Manager (Codeplex)
  14. ULS Log Viewer (Codeplex)
  15. CKSDev (Codeplex)
  16. .NET Reflector or
  17. JustDecompile (Free from Telerik)
  18. Notepad++
  19. Firebug

End User Tools

  1. Colligo Contributor Pro

Graphics Designing

  1. Photoshop
  2. GIMP

Administration

  1. PowerShell
  2. Axceler’s ControlPoint
  3. AvePoint Products

Training:

  1. Global knowledge http://www.globalknowledge.ca/training/course.asp?pageid=64&courseid=12991&catid=213)

Learning Resources:

  1. SharePoint Developer Center (MSDN) http://msdn.microsoft.com/en-us/sharepoint/aa905688
  2. SharePoint StackExchange http://sharepoint.stackexchange.com/
Share
Filed in Configuration, Guidance, Information, SP2010, Tips • Tags: , , ,

Solution for viewing HTML files in browser from SharePoint Document Library

By namwar - Last updated: Sunday, March 25, 2012

In SharePoint 2010 document library, if you click on a file with .html extension, you will notice that browser will open Save File dialogue box. This behaviour stops you to view HTML files directly in browser from document library and some times it is very annoying.

To resolve it and view HTML files in browser, here are the steps:

  1. Open SharePoint Central Administration
  2. Click Application Management
  3. Under Web Applications, click Manage web applications
  4. Click on your target web application to select it
  5. On ribbon, click on Web Application tab
  6. Open General Settings menu and click on General Settings
  7. General Settings UI Tab

  8. Scroll to Browser File Handling and change it from Strict to Permissive
  9. Browser File Handling

  10. Click OK to save your changes
  11. Thats it!

Now, go back and try to view HTML file, browser will display it. Enjoy!

Share
Filed in Architecture, Management, SP2010, Tips, Troubleshooting • Tags: , , , , , ,

Correct way of generating Source parameter value in your SharePoint Link

By namwar - Last updated: Tuesday, February 21, 2012

As you may already know that SharePoint uses Source parameter in query string to take you back to the page from where you came.

The value of the Source paramter must be properly encoded. Don’t worry, you do not need to write your own Javascript function to do this. Just use already provided function called

GetSource(defaultSource)

It will return you properly encoded string to pass as Source parameter value. Following is the logic inside this function:

  1. Try to retrieve the value Source parameter from current query string.
  2. if Source parameter found then return it by properly encoding and making sure it is safe to navigate.
  3. If there is no Source parameter in Query string then
    • Check if defaultSource has a non empty value,
    • if yes then return it by properly encoding and making sure it is safe to navigate.
    • Otherwise, return the current page url by properly encoding and making sure it is safe to navigate.
Share
Filed in How To, Information, JavaScript • Tags: , , , , , ,

Useful Javascript Functions and objects in SharePoint – Part 2

By namwar - Last updated: Monday, February 20, 2012
In my last article “Useful Javascript Functions and objects in SharePoint – Part 1“  I listed some useful javascript objects in SharePoint.
Today I will continue exploring useful functions.
DOM Management
  1. byid(id) = Return element for the given id
  2. newE(tag) = Create a new dom element of the given tag e.g. div etc.
  3. wpf() = return ASP.net form object for the current web part page
  4. GetEventSrcElement(e) = return source element for the given event object
  5. GetEventKeyCode(e) = Return key code of the currently pressed key for the given object
  6. GetInnerText(e) = Return inner html for the given object

HTML Encoding and Decoding

  1. escapeProperlyCoreCore(str, bAsUrl, bForFilterQuery, bForCallback) = Very useful function to perform any type of string escaping. Last three parameters are flags to perform deifferent type of escaping i.e.
    • bAsUrl = true, for url escaping
    • bForFilterQuery = true, for filter query escaping
    • bForCallback = true, for call back escaping
  2. escapeProperly(str) = Escapes the given string to make it valid SharePoint compatible string. It internally calls escapeProperlyCoreCore to perform the actual escaping
  3. escapeUrlForCallback(str) = Escapes the given string to make it valid url for call back
  4. encodeScriptQuote(str) = Replace the apostrophe i.e. ‘ to %27 in the given string
  5. STSHtmlEncode(str) = Encodes the reserved characters to their respective HTML entities in the given string. For example “<div>” will become &lt;div&gt;
  6. StAttrQuote(st) = Encodes the “&”, “ “ ” and carriage return to their respective HTML entities in the given string.
  7. STSScriptEncode(str) = Encodes the given string for use in script. It has the same functionality as SPEncode.ScriptEncode defined here
  8. STSScriptEncodeWithQuote = Encodes the specified string so that characters in embedded HTML tags are displayed as text in the browser, and writes the string in quotation marks
  9. escapeForSync(str) = Encodes the given string for syncing. Need further clarification.
  10. Vutf8ToUnicode(rgBytes) = Converts the given utf8 string to unicode
  11. unescapeProperly(str) = Unescapes the given escaped string

Validations

  1. PageUrlValidation(url) = Checks if the given string is a valid url or not.
  2. IndexOfIllegalCharInUrlLeafName(strLeafName) = Return the index of character in the given string which is illegal to be used in url leaf name.
  3. IndexOfIllegalCharInUrlPath(strPath) = Return the index of character in the given string which is illegal to be used in url leaf name.
  4. UrlContainsIllegalStrings(strPath) = Returns true if the given string contains an illegal character which can not be used in a url. Otherwise, return false.
  5. UrlLeafNameValidate(source, args) = Validates the url leaf name. Returns true if valid otherwise, false. Need further clarification.
  6. UrlPathValidate (source, args) = Validates the url path. Returns true if valid otherwise, false. Need further clarification.
  7. IsCheckBoxListSelected(checkboxlist) = Returns true, if the given checkbox is either null or at least one check box is checked in it.
  8. IsAccessibilityFeatureEnabled() = Returns true, if the accessibility feature is enabled by checking the cookie called “WSS_AccessibilityFeature”

Cookie Management

  1. DeleteCookie(sName) = Deletes the given cookie by setting its expiry date to 01-Jan-1970
  2. GetCookie(sName) = Returns the given cookie

Navigation

  1. navigateMailToLink(strUrl, strUrlNew) = Creates a mail to link for the given url
  2. GetUrlFromWebUrlAndWebRelativeUrl(webUrl, webRelativeUrl) = Creates a url by combining webUrl and relative url. It takes care of checking null webUrl and slash character at the end.

Syncing with other applications

  1. GetStssyncAppNameForType(strType,strDefault) = Returns an string similar to “Connect to Outlook” etc. depending on the given type.
  2. GetStssyncIconPath(strDefault, strPrefix) = Returns the path of icon image for the given syncing application type.
  3. ExportHailStorm ( ….. ) = Creates connection to Outlook. Check here for further details.

Miscellaneous

  1. DeferCall() = Not sure.
  2. AdmBuildParam(stPattern) = Not sure.

To be continued….

Share
Filed in Architecture, Concepts, Guidance, How To, Information, JavaScript • Tags: , , , , , , ,

Useful Javascript Functions and objects in SharePoint – Part 1

By namwar - Last updated: Sunday, February 19, 2012

SharePoint has a huge set of javascript functions and objects which are defined in essential SharePoint javascript files like init.js, core.js, forms.js etc. These files are necessary for SharePoint to function properly. There is no reason to reinvent the wheel by writing your own javascript function for something which is already provided by these core javascript files.
I will run a series of articles to list down necessary objects and functions provided by SharePoint. I hope you will find them useful.

Useful Objects

JSRequest : It is a global object which is used to get information about current page. It has following properties:

  1. QueryString : An array of Querystring key and values,
  2. FileName : Name of the current file e.g. default.aspx
  3. PathName : current path of the page

NOTE: Before using this object properties, always call JSRequest.Ensuresetup()

L_Menu_BaseUrl : Relative path for current site. e.g.  “/TestSite”. It is useful to construct web relative paths for ajax calls of web services etc.

L_Menu_LCID : Current culture Id e.g.  “1033″ for US English.  It is useful to retrieve culture specific files, if need.

L_Menu_SiteTheme : Current site theme name e.g. Lacquer. If no theme is applied then it will be empty.

browseris : This object has several properties to detect browser name, major and minor version, operating system version etc. For example, if you want to know whether the current browser is IE or not then check browseris.ie. If it is true then IE else others. To get full details of its properties, use FireBug.

LegalUrlChars : Array of all characters which are allowed in Url for SharePoint.

_spBodyOnLoadFunctionNames : Array of javascript function names to be executed just after DOM is fully loaded. If you want to execute any of your function once the page is fully loaded then add your function name in this array. For example _spBodyOnLoadFunctionNames.push(“MyFunction”);

_spUserId : User Id of the currently logged in user. It is an integer e.g. 1. You can use this value perform any logic against a currently logged in user.

ctx or ctx1 or ctx2 … etc. There can be many ctx objects in a single page. These objects are instances of ContextInfo class. They are used to provide user context information necessary to create Edit Control Block menu items. Please use FireBug to see the list of all properties available. Visit here for more info

g_ExtensionDefaultForRead : An array of file extension strings which are always checked out as Read only. For example, jpg, jpeg, bmp etc.

g_ExtensionNotSupportCheckoutToLocal : An array of file extension strings which are not allowed to checkout locally. For example, aspx, ascx, cmd etc.

Check my next post for available Javascript functions.

 

Share
Filed in Architecture, How To, Information, JavaScript, SP2010, Tips, Troubleshooting • Tags: , , , , , , , , , , , ,

Quickest way to create Slide Show from your Picture Library in SharePoint

By namwar - Last updated: Sunday, February 5, 2012

Although there are many scripts available on internet which helps you to create slide show or image carousel but none of them gives us the ability to display Title and Description along with the image. I searched quite a lot and then ultimately end up creating my own.

I must clarify that I have not written the entire code myself. What I have done is to use the following already available JavaScript libraries and then assemble them in a way which gives us a quickest way to create image carousel from SharePoint Picture Library:

Enough talk, now lets come to the point:)

Step 1: Plugin Setup

  1. Download the Easy Slider Plugin from http://cssglobe.com/lab/easyslider1.7/easyslider1.7.zip
  2. Unzip the file and Upload easySlider1.7.js to a document library.

Step 2: Note down the List ID

  1. Navigate to your Site Actions -> Site Settings
  2. Under Site Administration, click Site libraries and lists
  3. Click on your Picture Library name, to open it.
  4. Note down the value of parameter List as displayed in Url window of your Internet explorer. It will be something like {26EC0E08-3D8A-4C67-ABF5-909D572B3030}
  5. Add a content editor web part (CEWP) on your target page

Step 3: Set up Content Editor Web Part

  1. On your target page, add a content editor web part (CEWP)
  2. Paste the following code in Source Editor

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<!-- Step 1:  Download easy slider plugin fromhttp://cssglobe.com/lab/easyslider1.7/easyslider1.7.zip  -->
<script type="text/javascript" src="http://TestServer/TestSite/js/easySlider.js"></script>

	<script type="text/javascript">
	_spBodyOnLoadFunctionNames.push("startSlider");

    function startSlider() {
		//Step 2 Replace {26EC0E08-3D8A-4C67-ABF5-909D572B3030} with the ID of your picture library
        var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                     <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                        <listName>{26EC0E08-3D8A-4C67-ABF5-909D572B3030}</listName> \
                         <viewFields> \
                            <ViewFields> \
                               <FieldRef Name='Title' /> \
                           </ViewFields> \
                        </viewFields> \
                    </GetListItems> \
                </soapenv:Body> \
            </soapenv:Envelope>";
        $.ajax({
            url:  "//"+window.location.hostname+L_Menu_BaseUrl+"/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    };
    function processResult(xData, status) {

		//Uncomment the following line to see the raw xml received from lists.asmx
		//$("#rawXml").text(xData.responseText);

        $(xData.responseXML).find("z\\:row").each(function() {

			//Get relevant field values
			imageUrl="//"+window.location.hostname + "/" + $(this).attr("ows_FileRef").split(";#")[1];
            var description=getDescription( $(this).attr("ows_MetaInfo"));
			var title=$(this).attr("ows_Title");

			//Construct required HTML Markup
			var liHtml = "<li><h3>" + title + "</h3>" ;
			liHtml+="<IMG border=0 alt='" + title + "'src='" + imageUrl + "' >";
			liHtml+="<p>" + description + "</p>";
			liHtml+="</li>";

			//Add markup as line item in UL tag
            $("#imagesUL").append(liHtml);
        });

		//Start Slider
		//For full options, refer to http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
		$("#slider").easySlider({
			auto: true,
			continuous: true,
			controlsShow : false,
			speed : 800,
			pause : 4000
		});

		}
	function getDescription(metaInfo)
	{
		var description="";
		if(metaInfo!=null)
		{
			metaParts=metaInfo.split("\n");
			if(metaParts!=null && metaParts.length>0)
			{
				var i=0;
				do
				{
					if(metaParts[i].indexOf("vti_description")>-1)
					{
						var descParts=metaParts[i].split("|");
						if(descParts!=null && descParts.length>1)
						{
							description=descParts[1];
						}
					}
					i++;
				} while (i<metaParts.length && description=="" );
			}
		}
		return description;
	}
</script>
<style type="text/css">
#slider{border-bottom:2px solid #ccc; background:#eee; padding:5px;	font-size:x-small;}
#slider h5{font:italic medium Georgia, Times, serif; color:#555; padding:3px; margin-bottom:-10px; background:#c6c6c6;}
#slider h5 span{text-transform:lowercase; padding:5px; font:x-small normal Arial, Helvetica, san-serif;}
#slider div {font-size: x-small; padding:3px;}
#slider ul, #slider li{margin:0; padding:0; list-style:none;}
#slider li{width:310;	height:400px; overflow:hidden; padding:0px;}
#controls2 {padding:3px 0 0 0; text-align:right; width:300;}
#prevBtn, #nextBtn{}
#nextBtn{}
#prevBtn a, #nextBtn a{font-size:x-small; background-color:#ccc; color:#444; padding:2px; text-decoration:none;}
#nextBtn a{}

</style>
	<div id="rawXml" ></div>
   	<div id="slider">
		<ul id="imagesUL"/>
	</div>

Step 4: Update Code

  1. Replace {26EC0E08-3D8A-4C67-ABF5-909D572B3030} by the List ID you got in step 2, above
  2. Click OK, exit edit mode and Enjoy!

Notes:

  1. This code is a sample code and you may need to change the styles section to match your site’s theme.
  2. Please make sure all your images are of same size, if not, then please adjust the size in line 47 of source code.
  3. This code assumes the size of images as 300×300 pixels, if you need to change it then update the relevant size at line 98.

All credits goes to JQuery and easy slider plugin

Share
Filed in How To, JavaScript, jQuery • Tags: , , , , , , , ,

List of SharePoint Base Permissions with their Hex and Decimal Values

By namwar - Last updated: Sunday, October 23, 2011

Here is the list of all SharePoint base permissions valid for Windows SharePoint Services and SharePoint Foundation both, along with their Hex and decimal values. I hope it will help you to easily reference them in your projects.

Permission Name

Hex Value

Decimal Value

Description

AddAndCustomizePages

0×40000

262144

Add, change, or delete HTML pages or Web Part Pages, and edit
the Web site using a Windows SharePoint Services–compatible editor.

AddDelPrivateWebParts

0×10000000

268435456

Add or remove personal Web Parts on a Web Part Page.

AddListItems

0×2

2

Add items to lists, add documents to document libraries, and add
Web discussion comments.

ApplyStyleSheets

0×100000

1048576

Apply a style sheet (.css file) to the Web site.

ApplyThemeAndBorder

0×80000

524288

Apply a theme or borders to the entire Web site.

ApproveItems

0×10

16

Approve a minor version of a list item or document.

BrowseDirectories

0×4000000

67108864

Enumerate files and folders in a Web site using Microsoft Office
SharePoint Designer 2007 and WebDAV interfaces.

BrowseUserInfo

0×8000000

134217728

View information about users of the Web site.

CancelCheckout

0×100

256

Discard or check in a document which is checked out to another
user.

CreateAlerts

0×8000000000

549755813888

Create e-mail alerts.

CreateGroups

0×1000000

16777216

Create a group of users that can be used anywhere within the
site collection.

CreateSSCSite

0×400000

4194304

Create a Web site using Self-Service Site Creation.

NOTE: CreateSSCSite (0×400000) is a hidden base permission. It  is not
copied if you copy a built-in permission level using the “Copy
Permission Level” button at the bottom of ~/_layouts/editrole.aspx

DeleteListItems

0×8

8

Delete items from a list, documents from a document library, and
Web discussion comments in documents.

DeleteVersions

0×80

128

Delete past versions of a list item or document.

EditListItems

0×4

4

Edit items in lists, edit documents in document libraries, edit
Web discussion comments in documents, and customize Web Part Pages in
document libraries.

EditMyUserInfo

0×10000000000

1099511627776

Allows a user to change his or her user information, such as
adding a picture.

EmptyMask

0

0×0

Has no permissions on the Web site. Not available through the
user interface.

EnumeratePermissions

0×4000000000000000

4611686018427380000

Enumerate permissions on the Web site, list, folder, document,
or list item.

FullMask

0x7fffffffffffffff

9223372036854770000

Has all permissions on the Web site. Not available through the
user interface.

ManageAlerts

0×4000000000

274877906944

Manage alerts for all users of the Web site.

ManageLists

0×800

2048

Create and delete lists, add or remove columns in a list, and
add or remove public views of a list.

ManagePermissions

0×2000000

33554432

Create and change permission levels on the Web site and assign
permissions to users and groups.

ManagePersonalViews

0×200

512

Create, change, and delete personal views of lists.

ManageSubwebs

0×800000

8388608

Create subsites such as team sites, Meeting Workspace sites, and
Document Workspace sites.

ManageWeb

0×40000000

1073741824

Grant the ability to perform all administration tasks for the
Web site as well as manage content. Activate, deactivate, or edit properties
of Web site scoped Features through the object model or through the user
interface (UI). When granted on the root Web site of a site collection,
activate, deactivate, or edit properties of site collection scoped Features
through the object model. To browse to the Site Collection Features
page and activate or deactivate site collection scoped Features through the
UI, you must be a site collection administrator.

Open

0×10000

65536

Allow users to open a Web site, list, or folder to access items
inside that container.

OpenItems

0×20

32

View the source of documents with server-side file handlers.

UpdatePersonalWebParts

s         0×20000000

536870912

Update Web Parts to display personalized information.

UseClientIntegration

0×1000000000

68719476736

Use features that launch client applications; otherwise, users
must work on documents locally and upload changes.

UseRemoteAPIs

0×2000000000

137438953472

Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007
interfaces to access the Web site.

ViewFormPages

0×1000

4096

View forms, views, and application pages, and enumerate lists.

ViewListItems

0×1

1

View items in lists, documents in document libraries, and view
Web discussion comments.

ViewPages

0×20000

131072

View pages in a Web site.

ViewUsageData

0×200000

2097152

View reports on Web site usage.

ViewVersions

0×40

64

View past versions of a list item or document.

 

Share
Filed in Concepts, Configuration, Security, SP2010 • Tags: , , , , ,

What is the meaning of “Limited Access” in SharePoint?

By namwar - Last updated: Saturday, October 22, 2011

If you are wondering what is “Limited Access” in SharePoint and how does it affect you then here is the simple explanation:

“Limited Access” in SharePoint means a user has an access to an item of the page specifically but not the whole SharePoint list. Normally, we don’t manage individual item permissions and list items normally inherit their permissions from their parent list but sometimes you may need to share a document or a an item to another user who does not have access to the parent list of that item. In this case, you will break the inheritance for that item/document and give permission specifically to that item/document.

Now, since that document resides under its parent library therefore, user will automatically get the “Limited Access” to the parent list which will in turn allow the user to only access that specific document.

For more information, I will recommend you to read Michael Nemtsev article here

Share
Filed in Administration, Architecture, Concepts, Configuration, Management, Security, SP2010, Tips, Troubleshooting • Tags: , , , , , , ,

Continuous Integration of SharePoint Project by using TFS

By namwar - Last updated: Friday, August 26, 2011

SharePoint projects are some what special in the way they use assemblies and some time it is very difficult to setup your TFS build process for continuous integration. Today, SharePoint Developer Team has published an excellent step-by-step process to properly setup your TFS Build Process for SharePoint Projects. You can read the article here

This article guides about the following:

  1. How to configure the build server to properly compile the SharePoint projects?
  2. List of necessary SharePoint assemblies to make sure compilation succeeds.
  3. How to update Powershell script to add the required files on Build server?
  4. Steps to create build definition.
  5. How to setup build workflow?

I would highly recommend you to read this article before embarking on your next SharePoint project.

Share
Filed in Guidance, Information, Installation, Management, SP2010, TFS, Troubleshooting • Tags: , , , , , ,