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 March, 2013

Squadron – Backup & Restore Permissions

Posted by JP on March 31, 2013

In this article we can explore a new feature in Squadron for SharePoint 2010.

clip_image002

Squadron is a Free SharePoint Administration tool available at http://www.sharepointcto.com.

clip_image004

What is Backup & Restore Permissions Add-in?

This is a new add-in in SharePoint that allows backing up existing permissions in SharePoint securable object & restoring it elsewhere.

Following are the levels of backup possible:

· Web Application

· Site Collection

· Site

· List

· Item

Squadron also provides URL based filtering for backing up permissions. This will enable speed, context & reduce size of backup data.

What is contained in Permissions?

Following are the content of Permission:

1. Title

2. URL

3. User/Group Name

4. Members in Group

5. Owner if Group

6. Role Assigned

How to perform Backup?

Please follow the steps to perform backup:

Step 1: Execute Squadron

Execute Squadron from Start Menu > SharePointCTO folder. In the appearing scree se the URL.

clip_image006

Step 2: Click Permissions

From the left pane, click the Permissions item.

clip_image008

Step 3: Click Backup

Click on the Backup button in the appearing screen. You will get the following wizard.

clip_image010

Step 4: Check the Items

Expand the Web Application root item & Check the items to be backed up. You can right click & choose Check All command to check the sub items.

clip_image012

You can also use the Filter By Url on the bottom to filter by url.

Click the Next button to continue.

Step 5: View Permissions

In the next page you will see the Iterated Permissions as shown below:

clip_image014

The first column shows the Title of the Site / List / Item. The Type is displayed in the second column. The Url column is the key-column which will be used to identify the item uniquely.

The PermissionType column displays whether the permission is Unique or Inherited. The remaining rows contains the SharePoint Group / Domain User along with the role assignment.

Role Assignment can be Full Control, Contribute, Read or Custom Level.

Click the Next button to Save the file.

Step 6: Choose File

In the next page, choose the file name for saving the backup.

clip_image016

Step 7: Final Page

On clicking Next button you will see the last page which displays summary of the export.

clip_image018

It displays the number of web items, list items, library items along with unique/inherit permission types.

Click the Finish button to close the wizard.

Now we have successfully performed the Backup operation.

The file generated is in excel format & you may edit it for further optimizations. Please ensure the format of columns are retained.

Note: Please note that Folders (SPFolder) inside list/library are not included in permission backup.

How to perform Restore?

In the restore wizard, we are using a previous backup file to restore in a UAT/Production system. Click the Restore button from the Permissions Add-in.

clip_image020

You need to select the backup file in the next page.

clip_image022

In the next page you will be displayed the file contents as shown below:

clip_image024

In the next page choose the URL of the site to perform the backup.

clip_image002[1]

Please note that the URL column of backup file will be used to match the target items.

Please note that this feature is only available for SharePoint 2010.

clip_image026

On clicking Next you can see the matching URLs.

clip_image028

You can verify the Source Objects in file & the Destination Objects in the destination Site URL specified.

On clicking Next you will see the Confirm prompt.

clip_image030

Click the Yes button to continue..

The restore operation will be performed & you can see the result as shown below:

clip_image032

This concludes our Restore Operation.

References

Permissions & Permission Levels http://bit.ly/YoKoX8

Summary

In this article we have explore the new feature in Squadron 2010. I believe this feature will be useful in backing up existing permissions before applying new ones. The Backup & Restore can be applied combined in scenarios of UAT Backup & Production Restore OR vice-versa.

Advertisements

Posted in C# | Leave a Comment »

Squadron Exception >> Unable to find SPDeletedSite…

Posted by JP on March 29, 2013

While using Squadron you might have faced with following Exception:

image

The exception states unable to load type ‘Microsoft.SharePoint.Administration.SPDeletedSite’ from assembly ‘Microsoft.SharePoint, Version 14.0.0.0’ with Public Key Token

Description of Problem

The stated assembly should be registered in GAC (Global Assembly Cache) for working with Squadron.

Solution

As Squadron is built based on Server Object Model, it is expected to be executed in the SharePoint Server machine.

Following are the solutions recommended:

  1. Execute Squadron from a machine with the above Assemblies installed in GAC
  2. Install above Assemblies to GAC  (http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx)

On Success

After solving the problem, you can execute Squadron again.  If the problem is resolved, you can see the Squadron Main Screen without any errors.

image

Posted in C# | Leave a Comment »

Squadron – PowerShell Code Command

Posted by JP on March 27, 2013

Observing the SharePoint Administrators, I found that they need a tool for examining problems with site/list/item objects & a PowerShell code to fix the problem.

As we already integrated Explorer with Properties in Squadron, I thought of easing their second step of using PowerShell code.

clip_image002

Squadron is a Free SharePoint Administration tool available at http://www.sharepointcto.com.

clip_image004

What does PowerShell Code button do?

You can see the PowerShell Code button in the Explorer add-in.

clip_image006

The command is only available for:

1. Site Collection

2. Site

3. List

4. List Item

On clicking the command (button) you will get the PowerShell Code to point to the item.

For example, I am selecting the Site Collection object & clicking the button.

clip_image008

You can see the code in above screen. The code can be directly pasted to a PowerShell Editor for execution or debugging.

You need to enter your custom code after the last line of generated code 🙂 The generator helps in saving time skipping the plumbing work.

You can even launch PowerShell & PowerShell ISE using the buttons displayed.

Generate List Item Code

Both List & Library are internally Lists for SharePoint. So the list items & documents are the same List Item. You can select the item as shown below.

clip_image010

Click the PowerShell Code button to generate code.

clip_image012

You can launch the PowerShell ISE and paste the code there..

clip_image014

This concludes our article on PowerShell code command in Explorer add-in.

References

http://bit.ly/10uiVpB

Summary

In this article we have explored a possible useful Add-in command option of Squadron. Please let me know about more functionality you need in Squadron.

Posted in C# | Leave a Comment »

SharePoint 2013 Tutorials

Posted by JP on March 27, 2013

I am writing SharePoint 2013 articles for SharePointCTO web site, link below:

http://www.sharepointcto.com

image

You can find the articles there..

[image]

SharePoint 2013

Introduction

Installation

Basics

Site Collection & Site

List & Library

Web Part

Workflow

Tools

Central Administration

SharePoint Designer

PowerShell


Custom Development

Programming

Apps

Server Object Model

Client Object Model

More

Resources, Tools

Job Track

You are Welcome to visit the site by.. Happy SharePoint 2013!

Posted in C# | 4 Comments »

Squadron – Permissions Add-in

Posted by JP on March 26, 2013

In this article we can explore the new Permissions Add-in inside Squadron.

clip_image002

Squadron is a Free Administrative Tool for SharePoint. You can download it from:

http://www.sharepointcto.com/Squadron/Default.aspx

What is inside Permissions Add-in?

Permission Add-in helps with the following tasks:

1. Find permissions of site level, list level, item level

2. Distinguish between Unique & Inherited permissions

3. Save Reports

4. Provides wizards for Find, Copy, Delete, Backup, Restore permissions

clip_image004

Types of Permissions

In a quick overview of Permissions, there are basically 2 types:

Unique Permissions where we assign unique users/groups & permission levels.

Inherited Permissions where the securable object (site, list, item) inherits permissions from its parent.


How to Generate the Report?

Let us examine the steps to generate a report for a site collection.

Step 1: Enter URL

Run Squadron & in the appearing screen, enter the URL of the site. Please note that you should run this in SharePoint Farm Account context.

clip_image006

Step 2: Open Permissions

From the left hand side click the Permissions link.

clip_image008


Step 3: Set Options

You can set the options in the appearing screen.

clip_image010

Site: To include site objects check this item.

List & Library: To include list & library objects check this item.

Item: To include items & documents check this item.

Expand Groups: A permission entry can be a SharePoint Group or User. If it is a SharePoint Group, you might need to include the users contained inside it. Check this item for including users.

Show User Name: The user item will be having a Login Name (eg: DOMAIN\user) & a Display Name (eg: Full Name). You can choose this option to include the Display Name of the user as well.

Include Hidden: There could be hidden lists which are not visible in Quick Launch or in the All Site content page. Check this option to include those.

Unique Permissions Only: Check this option if you need only Unique Permission items.

Expand Inherited Groups: Usually the Inherited Permissions will be expanded in the parent object, as it is unique there. This checkbox enables you to expand the inherited groups too.

Filter By: Checking this option will enable a URL textbox where you can enter the URL to filter the result.

Highlight: Highlight Unique Permissions as Yellow & inherited ones as Green.

For the time being I have checked the following options:

clip_image011

Step 4: Generate

For generating the report, click the View Permissions from the left. You can see the result as shown below depending on your Site.

clip_image013

Step 5: Save Report

For saving the report, you need to right click on the grid & choose the option.

clip_image015

1. Save to Excel

2. Save to CSV

You may uncheck the option “Open after save..” if you do not wanted to launch your report file after save.

I have selected the option to save as Excel.

clip_image017

Enter the file name and click the Save button.

You will be viewing the file in Excel after saving.

clip_image019

This concludes our usage of Squadron Permissions add-in.

clip_image020

I wanted to iterate the Microsoft Recommendation of using SharePoint Groups instead of directly adding users to the site/list/item permissions. Groups are more easily manageable & easier understanding.

About the Wizards

The additional wizards are separately documented. Here is the screen shot of thee wizard screens.

clip_image022

References

http://bit.ly/10uiVpB

Summary

In this article we have explored about Squadron Permissions Add-in. I believe in real life scenario the add-in is useful in quickly analyzing a SharePoint site.

Posted in C# | Leave a Comment »

Set Permissions for Views

Posted by JP on March 23, 2013

I had a requirement from customer to set permissions for Views. You very well know that we cannot set permissions for Views. SharePoint 2010 out-of-the-box does not have support for view permissions.

Scenario

The Research department is having an Ideas Library. Following are the constraints:

1. Each employee can add / edit / delete documents to the library

2. Employee cannot view other employee’s documents

3. Research Head can view all the documents

4. Employee should not be able to change View

How to achieve this?

image

The common way of view creation with filter does not work here as the user may change the view. Plus the item filtering options for Lists & Survey Lists are not available for document libraries.

Users

Following are the users involved in this scenario:

1. Research Head

2. Engineer 1

3. Engineer 2

Solutions

There are 2 solutions for this problem:

· Create multiple views with filtering & use SharePoint Designer to set View Permission

· Modify default view to show only current user items & create a restricted page to show all items

We can try the second approach.


Steps

Step 1: Create Users

As the first step create the following users in Active Directory or in User Accounts.

1. Research Head (researchhead)

2. Engineer 1 (engineer1)

3. Engineer 2 (engineer2)

Step 2: Create Library

Create a new document library named Ideas Library and set contribute permissions for all users.

image

Step 3: Modify View

Open the Library and click on Library tab > Modify View button.

image

Modify the default view of the library by setting filter to [ME]

image

Click OK to save changes.


Step 4: Upload Documents

Open another browser & login as Engineer 1. Upload a document. Repeat the process for Engineer 2.

Now there are 2 documents, but each engineer can view only their documents.

image

Step 5: Create Page

Now create a new page.

image

Set the name of page as All Ideas Page

image

Choose the Insert tab > Existing list option.

image

Choose the Ideas Library and click OK button.

image

Save the changes to page.

image

Step 6: Set Page Permissions

Now choose Page Permissions.

image

Choose Stop Inheriting Permissions option

image

Delete existing users & add only the Research Head user.

image

Click Ok button to save changes.

image

image

If the buttons are not enabled, you might need to refresh the page.

Step 7: Test the Page

You can open the page from Site Actions > View All Site Content > Site Pages library.

image

Now you can try logging in as Research Head & the page should display all document items.

image

So this concludes our article. Now the engineers can post their ideas, without seeing each other’s. The Research Head can view all the submitted ideas. All are happy J

References

http://bit.ly/10uiVpB

Summary

In this article we have explored a real world scenario of setting permissions for views, although not direcly.

Posted in C# | Leave a Comment »

KNOWLEDGE SHEET – Stale Objects & HTTP 500 Error

Posted by JP on March 20, 2013

KNOWLEDGESHEET

 

Stale Objects & HTTP 500 Error

 

 

Scenario – I was working for Squadron > Permissions management module. The SPWeb objects in collection were invoking Update() method multiple times.  Additionally the same SPWeb object were used in child SPList objects.  As these SPWeb objects were obsolete, invoking the Parentweb.Update() from child objects made the entire web application fault by HTTP 500 error.

 

 

Solution: Create new SPWeb objects in the child list again

 

public void InvokeUpdate(SPList list)

 

{

 

  SPSecurity.RunWithElevatedPrivileges(delegate()

 

  {

 

    using (SPSite site = new SPSite(list.ParentWeb.Site.Id))

 

    {

 

      using (SPWeb web = site.OpenWeb(list.ParentWeb.Id))

 

      {

 

        site.AllowUnsafeUpdates = true;

 

        site.Update();

 

        site.AllowUnsafeUpdate = false;

 

      }

 

    }   

 

  });

 

}

 

Posted in C# | Leave a Comment »

Knowledge Sheet – Configuration Database Permission Solution

Posted by JP on March 15, 2013

Error – This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.
Scenario: In C# invoked the SPWebApplication.Lookup() method.
 
Solution 1: Add the current user to the SQL Server > Security folder.
image

Solution 2: Run the application in the context of Privileged user who has above access.

Use Command Prompt to execute the command:

runas /user:DOMAIN\USERNAME “YourApplicationPath”

clip_image001[4]

 Reference: http://technet.microsoft.com/en-us/library/cc771525(v=ws.10).aspx

Posted in C# | Leave a Comment »

Privacy on List Items – Out-of-the-box support

Posted by JP on March 8, 2013

In this article I would like to use a SharePoint Out of the Box Solution for a common problem. The problem is associated with a survey list where:

1. Items can be created by any user

2. But editing / deleting should be possible by the item created user

Example: A survey list for employee feedback

What is Out of the Box?

This is a term used to denote in-built features of SharePoint. Out-of-the-box solutions are preferred & encouraged as it is easier to perform in the short run & easier to manage in the long.

Possible Solutions

We can quickly jump into solutions like creating an Event Handler and on the Item Updated event we can ensure the user & cancel the event. But the drawback is that it requires code development, installation & maintenance.

Instead we can go for the Out-of-the-box solution – Modifying List Advanced Settings.

Create the List

To execute this please perform the following activities:

1. Create a List named My List from template Contacts.

2. Create a user named user1 and add to List Permissions, assign Contribute level

3. Create a user named user2 and add to List Permissions, assign Contribute level

4. Login as user1 and create a contact named User 1 Contact

5. Login as user12 and create a contact named User 2 Contact

clip_image002

Now the list looks like below:

clip_image004

clip_image006

Please use separate browsers with different session instance for users: Administrator, User1 & User2

Modify Advanced Settings

Now we can modify the List Advanced Settings. Open the list in Administrator mode & choose List Settings > Advanced Settings.

clip_image007

From the appearing page select the following options.

clip_image009

Click the OK button to save changes. Now you can see that:

User 1 can only view his own item:

clip_image011

User 2 can only view his own item:

clip_image013

Administrator can view both items:

clip_image015

clip_image006[1]

Please note that the Permission Levels determine the visibility.

1. Administrator is given Full Control permission level

2. User 1, User 2 are given Contribute permission level

References

http://bit.ly/10uiVpB

Summary

In this article we have seen a possible scenario of List Item Permissions. SharePoint consists of various options & out-of-the-box solutions we need to be aware with.

This solution is apt for Survey Scenarios, where multiple users are required to provide their feedback, but they should not see other’s feedbacks.

Please note that SharePoint 2010 also have a Survey list template.

Posted in C# | Leave a Comment »

Content Editor Web Part & CSS Tricks

Posted by JP on March 8, 2013

In this article I would like to inform you on the usage of Content Editor Web Part for CSS style manipulations.

What is Content Editor Web Part?

Content Editor Web Part is used to provide Formatted HTML Content to your web page. You can add a content editor web part following the steps below:

· Open the Page

· Choose Site Actions > Edit Page

· Click on Add Web Part

· Choose Content > Content Editor Web Part

· Save changes

clip_image002

You need to have Designer permission level to edit pages. Please make sure you consult your Governance Committee before making changes.

Why we need CSS style changes?

Your customer might require changes in the layout of SharePoint pages. Editing the master page would be a choice but it is much more costly in terms of effort & performance.

The customization requirements will be as:

1. Hiding the Quick Launch from the left side

2. Highlighting the Page Elements

3. Modifying the Calendar items display format

4. Modifying other common style elements

Little about CSS

Cascading Style Sheets allows us to modify the Look & Feel of HTML elements as a whole. For modifying a single element we can use the id property of the element.

For modifying items as a whole, we can use the class property of the element.


Hiding Quick Launch

In this example we can try hiding the Quick Launch from a page. Following are the steps involved:

1. Find the Quick Launch bar Division Id

2. Add code to hide the Division in Content Web Part

3. Hide the Content Web Part too

To start with open your site which is Okay to be played with:

clip_image004

Now you can see the Quick Launch in the above page. We need to find the Division Element Id of the Quick Launch Bar. For this click on F12 button or open Developer Tools from Internet Explorer. Move the cursor over the Quick Launch bar & click on it. You will get the class name highlighted as shown below:

clip_image005

We are taking the CSS class name highlighted in Green Color. Now edit the Content Editor Web Part and choose the HTML source from toolbar. clip_image007

Add the following code in the HTML Source:

<style>

. s4-notdlg

{

display: none;

}

</ style >

Please note that the above code hides the Quick Launch Bar by hiding the Division Class. Now save the changes to page & you can see the Quick Launch is hidden.

But Wait! The solution is not complete. You can see that there is space filled in the old quick launch position. We can remove that by using the margin-left property of division.

clip_image008

As the last step we needed to hide the Content Editor Web Part as well. Choose edit web part and choose the Hidden option from Layout category.

clip_image010

Click the OK button & now you can see that the Quick Launch is hidden.

Ghosting & Unghosting

Ghosting is the state on which pages are rendered from File System. Unghosting is the stage where the edited pages are residing in database and rendered from there.

Unghosted pages should reduce performance, but in negligible based on network traffic.

clip_image012


References

http://tinyurl.com/sp2010-contwp

http://tinyurl.com/sp2010-css

Summary

In this article we have explored Content Editor Web Part and CSS style manipulations. To summarize with following are the points worth keeping in mind.

1. Content Editor Web Part allows us to include HTML, CSS, Java Script

2. We can add CSS code to modify page elements

3. Content editor web part can be made hidden

4. Customizing Pages involve slight performance overheads

5. Unghosting occurs while editing pages

6. Get approval from SharePoint Governance committee before applying page modifications

Posted in C# | Leave a Comment »