Tuesday, October 26, 2010

SharePoint 2010 IQ1

Q. How does Ribbon works ?

Ans. A file called CMDUI.XML stays at the web front end which contains the Out-of-Box site wide Ribbon implementation i.e. all the Ribbon UI for the entire site. In addition to this you have a CustomAction for each ribbon component. These CustomActions have CommandUIExtentions block which has CommandUIDefinitions and CommandUIHandlers which make up the activity of the ribbon component. So, when the ribbon is loaded the CommandUIDefinition merges with Out-of-Box definition in the CMDUI.XML

Q. How will you use WebParts or other solutions Created in SharePoint 2007 in SharePoint
2010 ?


Ans. In SharePoint 2010 the 12 hive is now replaced by 14 hive, So we will rewrite and recompile any code that refers to files and resources in “12″ hive. In addition to we must recompile custom code written for Windows SharePoint Services 3.0 and Office SharePoint Server 2007 that does not run on IIS.

Q. What is the advantage in using Windows PowerShell over stsadm in SharePoint 2010 ?

Ans. Unlike stsadm, which accept and return text, Windows PowerShell is built on the Microsoft .NET Framework and accepts and returns .NET Framework objects.Windows PowerShell also gives you access to the file system on the computer and enables you to access other data stores,
such as the registry and the digital signature certificate stores etc..

Q. What is REST ? How is it used in SharePoint 2010 ?

Ans. REST (Representational State transfer) is a protocol (powered by ADO.NET services) which is used for getting data out of sharepoint via Url. It is mostly used to access data from sharepoint even when you are not in the sharepoint context.

Q. What datatype is retured by REST ?

Ans. REST does not return an object of type SharePoint Site\List. Instead, it returns an XML output.

SharePoint 2010 IQ For Developers

Q. What has Changed in SharePoint 2010 Object model?

Ans. Microsoft has replaced the "12 hive" structure that we had in SharePoint 2007 with "14 Hive" structure in 2010.

It has apparently added three new folders to its hive.

The Folders are :

* UserCode – files used to support sandboxed solutions
* WebClients – used for the client Object Model
* WebServices – New .svc files

Q. How would you deploy WebPart Using Windows PowerShell?

Ans. At the Windows PowerShell command prompt (PS C:\>), type the below
command :
Install -SPWebPartPack -LiteralPath "FullPathofCabFile" -Name "Nameof WebPart"

Q. How would you re-deploy the old custom solutions in SharePoint 2010.What Changes are needed to the old Solution files.

Ans. SharePoint 2010 object model contains many changes and enhancements, but our custom code will still compile and, will run as expected. You should however, rewrite and recompile any code that refers to files and resources in "12 hive". For Details See : SharePoint Object Model – Backward Compatibility

Q. How would you add a link in the Ribbon?

Ans. You can add any link or Custom Action under any of the existing tabs of the ribbon or can create a new a new tab and place your links under it.

Q. What does CMDUI.XML contain?

Ans. The definitions for the out-of-the-box ribbon elements are split across several
files in the SharePoint root, with TEMPLATE\GLOBAL\XML\CMDUI.XML being the
main one.

Q. What are the Disadvantages of Using LINQ in your Code?

Ans. LINQ translates the LINQ queries into Collaborative Application Markup
Language (CAML) queries thus adding an extra step for retrieving the items.

Q. What is different with SharePoint 2010 workflows ?

Ans. Some of the additions in workflow model are :

1. SharePoint 2010 workflows are build upon the the workflow engine provide .Net Framework 3.5.

2. In addition to the SharePoint lists we can now create workflows for SharePoint sites as well.

3. SharePoint Designer 2010 also has a new graphical workflow designer for designing workflows and deploying them directly to SharePoint.

4. Another Improvement in SharePoint Designer 2010 is that it now allows you to edit the out-of-the-box workflows that come with SharePoint.

SharePoint 2010 Object Model Backward Compatibility

SharePoint 2010 Object Model Backward Compatibility

Some Important things about SharePoint 2010 Object model and its backward compatibility.

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 contain object model upgrades that are designed to be compatible with existing solutions developed for Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007. Some namespaces, classes, and methods are now obsolete, but they are still available and will continue to work as expected in your custom code.

You can synchronize your customizations and applications with the upgraded versions of Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 after you have redeployed them.

The object model contains many changes and enhancements, but your custom code will still compile and, with one potential exception, it will run as expected. If in case, any of your customizations rely on list queries that can generate result sets in excess of 5,000 items or that scan all rows of lists that consist of more than 5,000 items, you must change the query size threshold.(See Later in the Post)..

Note: You must Re-compile or re-write your code in below conditions:

* You should rewrite and recompile any code that refers to files and resources in "12" hive.For example, if you have redeployed all of your files into the "14" folder and emptied your "12" folder, any references to files
under the "12" folder will not work. You will need to rewrite your code to refer the files in "14 Hive" instead of "12 Hive" to make it work.

* You must recompile custom code written for Windows SharePoint Services 3.0 and Office SharePoint Server 2007 that does not run on IIS (such as console applications and services).

* You should recompile custom code written for Office SharePoint Server 2007 if your solution includes a feature receiver that implements the FeatureInstalled, FeatureUninstalling, FeatureActivated, or Feature Deactivating methods and you are deploying by using either the Stsadm command-line tool or the timer service.

Lets Look at some of the custom solutions that you would be moving to SharePoint 2010.

Moving Using Solution Packages (.wsp Files)

You can simply deploy them as we did in SharePoint 2007. You dont need to recompile them(unless, your code has references to 12 hive). If however, you want to start upgrading your applications so that they use the most current classes and methods, you should recompile your code. The compiler warnings will tell you which elements of the object model are obsolete, andwhich newer alternatives you should use.

Moving Using Windows Installer Files

If you deploy your custom solutions by using Windows Installer (.msi) packages, be sure to change them so that your custom files are deployed to their correct locations in the "14" folder. This is especially true if you are
deploying files to locations other than the TEMPLATE\FEATURES folder.

Moving Site templates

Site templates are deprecated. If you need to redeploy a site template to either SharePoint Foundation 2010 or SharePoint Server 2010, follow these steps:

1. Create a site from the site template.

2. Install SharePoint Foundation 2010 or SharePoint Server 2010 on your existing server farm or on a new server farm. If you install the upgrades on a new server farm, attach the content database that contains the site that you created to the new farm.

3. On the new installation, choose Save Site as Template from the Site Settings page. This creates a solution package with a .wsp file name extension.

CSS Changes

When you upgrade to either SharePoint Foundation 2010 or SharePoint Server 2010, you are able to choose either backward compatibility mode or the upgraded user interface. You can however, switch between backward compatibility mode and the new interface at the site-collection level or site level.

Since, the UI has changed significantly in both SharePoint Foundation 2010 and SharePoint Server 2010, any customizations(made to SharePoint 2007 CSS) that rely on specific CSS classes and UI elements will work only in backward compatibility mode.

A property SPWeb.UIVersion is also available for developers, to programmatically get or set the UI version (3 for backward compatibility mode and 4 for the new interface).

Themes:

Themes no longer exist in SharePoint Foundation 2010 and SharePoint Server 2010, so any customizations and design work that you have done with themes will not be imported into the new interface.

Custom Actions and Toolbar Additions:

Most custom actions, including those targeted at links and edit control block (ECB) menus, continue to work as expected in the upgraded interface. Because the toolbar is replaced by the ribbon, most custom actions that add buttons to a toolbar will be placed in the Custom Commands tab of the ribbon.
Note : Any Custom Action Element that uses the ControlAssembly attribute,the ControlClass attribute, or the ControlSrc attribute, however, will not appear in the new interface.

Site definition :
 
Migrate sites to a supported, predefined site definition, then apply custom features by using solution deployment. You can also continue to use a custom site definition. You do not have to create a new site definition based on SharePoint Server 2010.

Event handler : Rewrite and redeploy as a feature.

JavaScript : In some cases, you might have to adjust the scripts to work with the new page model. Verify that it works on an upgraded site, and in both Visual Upgrade modes.

Conclusion:

Because the changes to the API in the upgrades are backward compatible, you should not have to make any changes to your custom code before you redeploy it in either SharePoint Foundation 2010 or SharePoint Server 2010. All deprecated elements of the API continue to be available to you, so that you have time to review the newer elements of the API before incorporating them into your customizations.

Monday, October 25, 2010

SharePoint 2010 Workflows

SharePoint 2010 Workflows

A quick view on whats new with SharePoint 2010 Workflows :

1. SharePoint 2010 workflows are build upon the workflow engine provided .Net
Framework 3.5.

2. List and Site workflows - In addition to the SharePoint lists we can now create
workflows for SharePoint sites as well. These are called as "Site Workflows".

3. SharePoint Designer 2010 Changes - MS has provided a new graphical workflow
designer for designing workflows. These workflows can be deployed in SharePoint
Server directly from the designer.

4. Editing Out-of-Box workflows - Another Improvement in SharePoint Designer
2010 workflows is that it now allows you to edit the out-of-the-box workflows that
come with SharePoint.

5. Re-usable Workflow - In addition to above, with Designer 2010 you can also
create reusable declarative workflows. That means unlike SharePoint 2007 designer
workflows, you don't have to bind a workflow to a specific list. You can resuse them
by binding it to more than one list or multiple lists.

6. User profile in Workflow - User Profile data can now be bound to properties in
workflow. This will make it possible to get information about the SharePoint user
profile in the workflow itself.

7. Moving SharePoint Designer Workflows - The resuable designer workflows can
now be moved to another SharePoint server or to Visual Studio 2010 with a
workflow .wsp file. "Save as Template" command can be used to create the WSP
file for the workflow.

8.Changes in List Events - SharePoint 2010 adds four new workflow Event
Receivers for list based workflows. The four workflow event receivers available are
Starting, Started, Postponed and Completed. These are similar to other SharePoint
list\library event receivers and they execute code on the server in response to the
event.

9. Workflow Templates - To make development easier, Visual Studio 2010 includes
event receiver project types to make using the workflows and events fairly simple.

Now to Start developing workflows what do you need.

1. SharePoint designer - If you need to customize the Out-of-box workflow or wants
to create a "not so complex" reusable workflow. You can however, deploy your
designer workflow in any sharepoint enviornment using a wsp file. See Move
Designer workflow using wsp

2. Microsoft Visio - If you want to design a workflow which has complex workflow
chart, you can design it in Viso and later it can be pulled in to SharePoint designer.
Also, note that you can only create Sequential workflows in viso.

3. Creating Worflow in VS - Visual Studio 2010 provides templates to create
workflows and creates events for the workflow.

Lets look at some of the Videos available for creating workflows using all above
methods.

Create a User Group using Client Object Model

//get the connection

ClientContext ctx = new ClientContext(“http://SPSite”);

//create the group

GroupCreationInformation grp = new GroupCreationInformation();

grp .Title = “Your New Group”;

grp .Description = “This is a custom group created using the client object model”;

//add it to the list of site groups

Group newgrp = ctx.Web.SiteGroups.Add(grp);

//Get a role.

RoleDefinition rd = ctx.Web.RoleDefinitions.GetByName(“Permission level Name”); // – > To
Create a Custom Role definition or Permission level see my post Here

//create the role definition binding collection

RoleDefinitionBindingCollection rdb = new RoleDefinitionBindingCollection(ctx);

//add the role definition to the collection

rdb.Add(rd);

//create a RoleAssigment with the group and role definition

ctx.Web.RoleAssignments.Add(grp, rdb);

//execute the query to add everything

ctx.ExecuteQuery();

Create Custom Permission level using Client Object model

Create Custom Permission level using Client Object model –

ClientContext ctx = new ClientContext(“SPSiteurl”);

//create a new base permission

BasePermissions perms = new BasePermissions();

var _basePerm = | SPBasePermissions.AddListItems| SPBasePermissions.EditListItems;

perms.Set((PermissionKind)Enum.Parse(typeof(PermissionKind), _basePerm));

//create the construct for a new role definition

RoleDefinitionCreationInformation rdInfo = new RoleDefinitionCreationInformation();

//set the perms

rdInfo.BasePermissions = perms;

//set a descriptionrdInfo.Description = “Custom Role definition created with the client object
model”;

//set the name

rdInfo.Name = “My custom Permission level”;

//add the definition to the web collection

RoleDefinition rd = ctx.Web.RoleDefinitions.Add(rdInfo);

//execute to create

ctx.ExecuteQuery();

Now Assign a user this custom role definition –

/get the group

RoleDefinition rd = ctx.Web.RoleDefinitions.GetByName(“My custom Permission level”);

//get the user object

Principal usr = ctx.Web.EnsureUser(“domain\isha”);

//create the role definition binding collection

RoleDefinitionBindingCollection rdb = new RoleDefinitionBindingCollection(ctx);

//add the role definition to the collection

rdb.Add(rd);

//create a RoleAssigment with the user and role definition

ctx.Web.RoleAssignments.Add(usr, rdb);

Creating DashBoards Using SharePoint 2010

Creating DashBoards Using SharePoint 2010.

To create a dashboards in SharePoint 2010, you would use the newly integrated part of the SharePoint Server 2010 Enterprise called PerformancePoint. PerformancePoint Services is a performance management service that you can use to monitor and analyze your business or you can say that, PerformancePoint Services is Microsoft’s dashboard delivery tool, which now is part of the SharePoint Server 2010 Enterprise platform. PerformancePoint Services enables you to create rich, context-driven dashboards that aggregate data and content to provide a complete view of how your business is performing at all levels.

What will PerformancePoint give me?

It provides you with flexible and easy-to-use tools for building Key Performance Indicators (KPIs), Scorecards, Analytic Charts and Grids, Reports, Filters and Dashboards.Each of these components are unique to PerformancePoint Services and provide functionality that interacts with a server component that handles the hard parts like data connectivity and security.

What is PerformancePoint Services as a service application -

As you know that In SharePoint Server 2010 services are no longer contained within a Shared Service Provider (SSP) instead you can create a service application for each service and can share them with various existing web applications. To understand better, PerformancePoint Services will be one of the Service that will stay in the application server with a database something like “PerformancePoint Services Service database” in the Sql server box.

What is Secure Store Service: – This service application stores the password for the
PerformancePoint Services unattended account.

What are the Features of PerformancePoint Services

* With PerformancePoint Services, the dashboards and dashboard items are stored and secured within SharePoint lists and libraries, providing you with a single security and repository framework. The new architecture also takes advantage of SharePoint Server scalability, collaboration, backup and recovery, and disaster recovery capabilities.

* The Decomposition Tree is a new visualization report type available in PerformancePoint Services. You can use it to quickly and visually break down higher-level data values from a multi-dimensional data set to understand the driving forces behind those values. The Decomposition Tree is available in scorecards and analytic reports and ultimately in dashboards.

* You can access more detailed business information with improved scorecards. Scorecards have been enhanced to make it easy for you to drill down and quickly access more detailed information. PerformancePoint scorecards also offer more flexible layout options, dynamic hierarchies, and calculated KPI features.

* Better Time Intelligence filtering capabilities that you can use to create and use dynamic time filters that are always up to date. Other improved filters improve the ability for dashboard users to quickly focus in on information that is most relevant.

* Ability to include and link PerformancePoint Services Web Parts together with other PerformancePoint Services Web parts on the same page.

* Easier to author and publish dashboard items by using Dashboard Designer.

* The KPI Details report is a new report type that displays contextually relevant information about KPIs, metrics, rows, columns, and cells within a scorecard. The KPI Details report works as a Web part that links to a scorecard or individual KPI to show relevant metadata to the end user in SharePoint Server.

* Create analytics reports to better understand underlying business forces behind the results. Analytic reports have been enhanced to support value filtering, new chart types, and server-based conditional formatting.

What is this Dashboard Designer ?

PerformancePoint Dashboard Designer is the design tool you will use to build key performance indicators (KPIs), indicators, scorecards, reports, filters, data sources, and dashboards. It also enables you to deploy your finished dashboards to SharePoint.

Prerequisites for creating dashboards

1. Activate the SharePoint Server Publishing Infrastructure feature. PerformancePoint Services uses this feature to perform dashboard publishing.

2. Activate PerformancePoint Services Site Collection Features feature. This feature adds PerformancePoint content types and a Business Intelligence Center site template.

3. Activate the SharePoint Server Enterprise Site Collection Features feature. This feature  enables Excel Services, Visio Services, and Access Services, included in the SharePoint Server Enterprise License.

4. Create a new Business Intelligence Center site by clicking Site Actions ➪ New Site, and then choose Business Intelligence template.

5. Create an Unattended Service Account.

In PerformancePoint Services, you create the unattended account directly in the PerformancePoint Services application settings. In this case, the password is stored in Secure Store Service and the actual username is stored in the PerformancePoint Services database.

An unattended account can be created using the following steps:
1. Browse to the Central Administration Site.
2. From the Application Management category, choose Manage service applications.
3. From the list of existing service applications, click PerformancePoint Service Application.
4. Click the PerformancePoint Service Application Settings link.
5. Specify the unattended service account for PerformancePoint and click OK.


To get started Open the Dashboard Designer. To do this follow the Steps below

1. In Internet Explorer, navigate to the Business Intelligence Center site that you must have created.
2. Click the Create Dashboards link, and then click Start using PerformancePoint Service link.
3. From the PerformancePoint Services page, click the big button that says Run Dashboard Designer. This will download and install the PerformancePoint Dashboard Designer to your workstation.  Once the executable fi le is downloaded and installed on your computer, the PerformancePoint Dashboard Designer appears. Once the Dashboard Designer is installed, you have an empty workspace. A workspace is a primary container for all of the elements that you can use to build your dashboard, and it keeps its content synched  with the site from which it was launched.

Creating Your Dashboard

Before we get started with building a dashboad lets just create a Dashboard Datasource first.

To create a Dashboard Datasource follow the below steps :

1. Right – click the Data Connections folder in the Workspace Browser, and then select New ➪
Data Source.
2. From the Select a Data Source Template menu, choose the Analysis Services template to create a datasource that connects to Microsoft SQL Server Analysis Services, and click OK. Next Configure the Connection Settings.
3. Watch for Cache Lifetime setting. The value of this textbox (in minutes) indicates the interval
of refreshing the dashboard information from the backend datasource.
4. Click Test Data Source to make sure that your connection settings are correct.
5. Switch to the Properties tab and change the Name of your datasource.

6. Save the new datasource by right – clicking it in the Workspace Browser, and then selecting
Save.

Creating KPI

Now that we have our connection ready lets create our key performance indicator (KPI). In order to create a new KPI to track what ever you wanna track for your company, you need to follow these steps:

1. Right – click the PerformancePoint Content folder and select New ➪ KPI.
2. In the Select a KPI Template dialog, select Blank KPI, and then click OK.
3. And once you have your KPI created, you can define your actual and Target values. Also,
select the data source and the measure.
4. Click OK to close the dialog.
5. Select the Target row, and click the Set Scoring Pattern and Indicator button in the Thresholds area.
6. Next, In the Edit Binding Settings dialog, select the fi rst option (Band by normalized value of Actual/Target) from the Banding method drop – down, and then click Next.
7. In the Select an Indicator step, select an indicator to use for the target that clearly shows
whether the goal is met. You can choose from a collection of indicator templates available in
PerformancePoint Dashboard Designer. Once you are done, click Next.
8. In the last step of the wizard, leave the value intact and click Finish.
9. Save the KPI by right – clicking it in the Workspace Browser, and then selecting Save.

Create Users and Add them to a Group using Client Object Model

Create Users and Add them to a Group using Client Object Model

//get the connection

ClientContext ctx = new ClientContext(“http://SPSite”);

//get the group

Group grp = ctx.Web.SiteGroups.GetById(GroupId); -> get group id ( See Post Get all users and
groups client object model sharepoint 2010

//create the user object
UserCreationInformation usr = new UserCreationInformation();

usr.LoginName = “Domain\isha”;

usr.Email = “ikapoo@Oursite.com”;

usr.Title = “Programmer”;

//add it to the group

grp.Users.Add(usr);

//execute the query to add the user

ctx.ExecuteQuery();

Powershell script for getting all the webparts in a SharePoint Page

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

[System.Reflection.Assembly]::LoadWithPartialName(“System.Xml”)

$webApp=[Microsoft.SharePoint.Administration.SPWebApplication]::Lookup(“http://servernam
e”)

foreach($site in $webApp.Sites)

{

$web=$site.RootWeb

$file=$web.GetFile(“MyWebPartPage.aspx”)

if($file.Exists)

{

$wpManager=$web.GetLimitedWebPartManager(“Default.aspx”,[System.Web.UI.WebControls
.WebParts.PersonalizationScope]::Shared)

foreach($webPart in $wpManager.WebParts)

{

if($webPart.GetType().Name -eq “myContentEditorWebPart”) -> Getting my ContentEditor
WebPart.

{

$wp=[MicroSoft.SharePoint.WebPartPages.ContentEditorWebPart]$webPart
}
}
}
}

Programmatically adding documents to a document set using SharePoint 2010

Programmatically adding documents to a document set using SharePoint 2010.

In continuation with the previous post about how to create a document sets programmatically,
here i will post a little code snippet for adding a document to this document set that we just
created in our previous post.
For this example i am adding a file to our custom document set which already exists on
SharePoint server. You can however, use the file upload control to browse and add a file to your
docuemntset.

void addDocumentToDocuemntSet()
{

// Get the existing file
SPFile spfile = web.GetFile(“http://SPSite:8080/Lists/DemoLib/abc.txt”);

byte[] documentBytes = new byte[spfile.TotalLength];

if (spfile.Exists)
{
FileStream fs = new FileInfo(spfile.url).OpenRead()

fs.Read(documentBytes, 0, (int)fi.Length);

//add the default document to your document set template

newDocumentSetTemplate.DefaultDocuments.Add(spfile.Name,
web.ContentTypes["Document"].Id, documentBytes);

}

Programmatically Creating Document sets in sharepoint 2010

Programmatically Creating Document sets in sharepoint 2010.

You can create a document set using sharePoint object model, SharePoint Client OM and also
using SharePoint 2010 web services.

This example shows how to create document sets using SharePoint object model.

public static void CreateDocumentSetContentType(string libraryUrl)
{

using (SPSite site = new SPSite(libraryUrl))
{
using (SPWeb web = site.OpenWeb())
{

//create the new document set contenttype
SPContentType newDocumentSet = web.ContentTypes.Add (new
SPContentType(web.ContentTypes["Document Set"],web.ContentTypes,
“MydocumentSet”));

//get a an instance of DocumentSetTemplate for the new document set
DocumentSetTemplate newDocumentSetTemplate =
DocumentSetTemplate.GetDocumentSetTemplate(newDocumentSet );

//add allowable content types
newDocumentSetTemplate.AllowedContentTypes.Add
(web.ContentTypes["Document"].Id);

//add a shareable property
newDocumentSetTemplate.SharedFields.Add(newDocumentSetContentType.Fields["Module"]);

newDocumentSetTemplate.Update(true);
newDocumentSet .Update();
web.Update();
}
}
}

Programmatically get all users and groups using client object model

 Programmatically get all users and groups using client object model.

The code below shows you how to query users and groups using client object model. The client
OM includes the GroupCollection,Group,UserCollection,and User objects to make working with
users and groups easier.The client OM also has access to built – in groups such as the owners,
members, and visitors groups. You can
access these off your context object using the
AssociatedOwnerGroup,AssociatedMemberGroup,and AssociatedVisitorGroup properties,
which return a Group object.

function GetUsersGroups()
{

ClientContext context = new Microsoft.SharePoint.Client.ClientContext(“http://SPSite”);

GroupCollection groupCollection = context.Web.SiteGroups;
context.Load(groupCollection,
groups = > groups.Include(
group = > group.Users));

context.ExecuteQuery();

foreach (Group group in groupCollection)
{
UserCollection userCollection = group.Users;

foreach (User user in userCollection)
{
MessageBox.Show(“User Name: ” + user.Title + ” Email: ” +
user.Email + ” Login: ” + user.LoginName);
}
}
//Iterate the owners group
Group ownerGroup = context.Web.AssociatedOwnerGroup;
context.Load(ownerGroup);
context.Load(ownerGroup.Users);
context.ExecuteQuery();
foreach (User ownerUser in ownerGroup.Users)
{
MessageBox.Show(“User Name: ” + ownerUser.Title + ” Email: ” +
ownerUser.Email + ” Login: ” + ownerUser.LoginName);
}
context.Dispose();
}

Programmatically get permissions for all the users using client object model

Programmatically get permissions for all the users using client object model.

Firstly, to better understand about SPRoleDefinition and SPRoleAssignment read below.

SPRoleDefinition represents the levels such as “Full Control”, “Contribute”, while a Role
Assignment contains a collection of Role Definitions.
Any object that inherits from SPPrincipal can be assigned a SPRoleAssignment. For e.g. an
SPPrincipal such as a logged in user(SPUser type) called “isha”, can have a role assignment that
points you to two SPRoleDefinitions, “Full Control” and “Design”, thereby giving you a union
of SPBasePermissions between Full Control and Design.

Here is a simple code snippet to get SPRoleDefinitions for all the users in a site.

private static void GetUserRoles()
{
using (SPSite site = new SPSite(SPsiteUrl))
{

SPWeb web = site.OpenWeb();
Console.WriteLine(“\n\n Roles Assignments:”);

foreach (SPRoleAssignment roleA in web.RoleAssignments)
{
Console.WriteLine(“The following Role definition bindings exist for ” +
roleA.Member.Name);
foreach (SPRoleDefinition roledef in roleA.RoleDefinitionBindings)
{
Console.WriteLine(roledef.Name);
}
}
Console.ReadLine();
}
}

Search scopes for your search service application in SharePoint 2010

SearchServiceApplicationProxy;

// Service Application Info object to retrieve the application id for the search service.
SearchServiceApplicationInfo searchApplictionInfo =
searchApplicationProxy.GetSearchServiceApplicationInfo();

// Retrieve the search application instance for the specified id.
SearchServiceApplication searchApplication =
Microsoft.Office.Server.Search.Administration.SearchService.Service.SearchApplications.GetV
alue (searchApplictionInfo.SearchServiceApplicationId);

//get the current scopes defined in the search server
Scopes scopes = new Scopes(searchApplication);

Programmatically get permissions for list and listitems using client object model

Programmatically get permissions for list and listitems using client object model.

In this Post we have two code snippets, one for retrieving the Permissions on a specific list and
other for getting the Permissions on a specific Item using Client Object model.

Get Permissions for a List –

//get the Conext
ClientContext ctx = new ClientContext(“SPSiteUrl”);

//get the list
List myList = ctx.Web.Lists.GetByTitle(“My List”);

IEnumerable roles = null;
roles = ctx.LoadQuery(
myList.RoleAssignments.Include(

roleAsg => roleAsg.Member,

roleAsg => roleAsg.RoleDefinitionBindings.Include(

roleDef => roleDef.Name, // for each role def, include roleDef’s Name

roleDef => roleDef.Description)));

ctx.ExecuteQuery();

Retrieving permissions for a Specific item - The Code is similar to the above code but i am
using SecurableObject to hold the ListItem. Just to make things easy.

SecurableObject curObj = null;

ListItem curItem = ctx.Web.Lists.GetByTitle(“My List”).GetItemById(ItemId); -> Use ItemId of
the Item.

//plug it into our query object
curObj = curItem as SecurableObject;

IEnumerable roles = null;

roles = ctx.LoadQuery(

curObj.RoleAssignments.Include(

roleAsg => roleAsg.Member,

roleAsg => roleAsg.RoleDefinitionBindings.Include(

roleDef => roleDef.Name, // for each role def, include roleDef’s Name

roleDef => roleDef.Description)));

ctx.ExecuteQuery();

SharePoint_Permissions_Matrix

http://blogs.msdn.com/b/markarend/archive/2008/02/14/sharepoint-2007-permissions-matrix.aspx




Print current Page Sharepoint



To create the button, add a Content Editor Web part, select the source editor and put the follow code:

<script>
function printWindow(){
bV = parseInt(navigator.appVersion)
if (bV >= 4) window.print()
}
</script>
<img src="/imagens/print_ico.jpg" alt="Print This Page">
<a href="javascript:printWindow()">Print This Page</a>

SharePoint List Templates

When we are creating List using elemnts.xml and feature.xml, need to know what Template ID code to use.
here is a list can help you.

Template ID Description
100 Generic list
101 Document library
102 Survey
103 Links list
104 Announcements list
105 Contacts list
106 Events list
107 Tasks list
108 Discussion board
109 Picture library
110 Data Sources list
111 Site Template Gallery
113 Web Part Gallery
114 List Template Gallery
115 XML Form Library (InfoPath)
120 Custom grid for list
200 Meeting Series list
201 Meeting Agenda list
204 Meeting Decisions list
207 Meeting Objectives list
210 Meeting text box
211 “Things to Bring” Meeting list
212 Meeting Workspace Pages list
300 Portal Sites list
1100 Issue Tracking list
2002 Personal document library
2003 Private document library

What Is Sharepoint?

 Sharepoint is a website wherein team members can see documents and folders created by them on windows platform and are accessible over the web.

Features of Sharepoint
  • Collaboration – Collaboration means working together.  Sharepoint helps you to share information about project to team members through organise way.
  • Document Management – Document management helps you to manage documents in a structured way and allows you to share documents to authenticate users through the use of versioning, metadata, workflows, and search.
  • Portal – Portal provides interface through which you can able to access information and share information over the web.
Example of Document Management with Sharepoint:
Let say you have Business Requirement documents, which needs to be shared among group of team members, than sharepoint is smart choice.
  • Sharepoint allows to edit document, save document and even versioning of document.
  • Documents are accessible to authenticate users only.
  • You can also able to view who had previously edited this document including all required details such as date and time of editing document, what is been edited, etc.
  • It is much more than just document sharing, it also provide workflow. Example: Leave letter submitted by employee needs to be  approved by team leader and manager can used workflow, where in employee would get notification whenever any of them get approved the leave, by this way employee is happy as he get latest status of his leave approval, also manager doesn't needs to remember all the task, as he can able to view that leave request in its pending task.