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

Blog Moved to www.jeanpaulva.com

Posted by Editor on February 26, 2014

Please redirect & subscribe at www.jeanpaulva.com

About these ads

Posted in C# | Leave a Comment »

SharePoint 2013 Apps Explored

Posted by Editor on April 23, 2013

An overview of SharePoint 2013 Office Store Apps is posted @ SharePointCTO!

You can visit using the link below.

http://www.sharepointcto.com/View.aspx?id=20

image

Posted in C# | Leave a Comment »

SharePoint 2013 New Features

Posted by Editor on April 21, 2013

I have created a PowerPoint Slide (PPT) describing features of SharePoint 2013.

It could be useful in refreshing for interviews, demonstrating to clients, deciding on upgrade etc.

Please click the link below to read..

image

Please let me know your comments here..

Note: Existing subscribers can register in site SharePointCTO for SharePoint 2013 articles.

Posted in C# | Leave a Comment »

How to get SharePoint Solutions through Code?

Posted by Editor on April 21, 2013

In this article we can explore how to get SharePoint Solutions through code. We are using Server Object Model to retrieve the solutions.

As you know there are 2 types of Solutions in SharePoint:

1. Sandboxed Solutions

2. Farm Solutions

Are Sandboxed & Farm Solutions retrieved differently?

Yes! They both are deployed through different methods & they are retrieved through different object models.

clip_image002

Sandboxed Solution is represented by SPUserSolution class & Farm Solution is represented by SPFarmSolution class.

How to get Sandboxed Solutions?

Sandboxed Solutions are deployed in the Site Collection level. (Feature Activation is different where we activate both for Site Collection & Site levels)

Following is the property to get User Solutions.

site.Solutions

Following is the code to retrieve all User Solutions in a Site Collection:

using (SPSite site = new SPSite("http://localhost"))

{

foreach (SPUserSolution solution in site.Solutions)

{

Console.WriteLine(solution.Name);

Console.WriteLine(solution.SolutionId);

Console.WriteLine(solution.Status);

}

}

How to get Farm Solutions?

Farm Solutions exists in the Farm level. Following is the property to get Farm Solutions.

SPFarm.Local.Solutions

Following is the code to retrieve all Farm Solutions.

foreach (SPSolution solution in SPFarm.Local.Solutions)

{

Console.WriteLine(solution.Name);

Console.WriteLine(solution.SolutionId);

Console.WriteLine(solution.Status);

}

Now let us see installing solutions through the Server Object Model.

Install Sandboxed Solution

Installation of a Solution is a 2 step process consisting of:

1. Adding Solution to Gallery

2. Activating Solution

Following is the code to add solution to gallery:

using (SPSite site = new SPSite("http://localhost"))

{

SPDocumentLibrary gallery

=(SPDocumentLibrary)site.GetCatalog(SPListTemplateType.SolutionCatalog);

SPFile file = gallery.RootFolder.Files.Add("SandboxedSolution.wsp",

File.ReadAllBytes("SandboxedSolution.wsp"));

SPUserSolution solution = site.Solutions.Add(file.Item.ID);

}

Remove Sandboxed Solution

For removing a solution & deactivating its features, following code can be used:

using (SPSite site = new SPSite("http://localhost"))

{

SPUserSolution solution = site.Solutions.Cast<SPUserSolution>().

Where(s => s.Name == "Your Solution").First();

site.Solutions.Remove(solution);

}



Install Farm Solution

For installing Farm Solution, following code can be used:

private static void InstallFarmSolution()

{

SPSolution solution = SPFarm.Local.Solutions.Add("File Path here");

solution.Deploy(DateTime.Now, true, GetAllWebApplications(), true);

}

We need to specify the solution path for the above method. The solution will be installed to all web applications as per the above code. The body of GetAllWebApplications() method is given below.

public static Collection<SPWebApplication> GetAllWebApplications()

{

Collection<SPWebApplication> result = new Collection<SPWebApplication>();

SPServiceCollection services = SPFarm.Local.Services;

foreach (SPService s in services)

{

if (s is SPWebService)

{

SPWebService webService = (SPWebService)s;

foreach (SPWebApplication webApp in webService.WebApplications)

{

result.Add(webApp);

}

}

}

return result;

}

Remove Farm Solution

Removing Farm Solution is termed as Retract Solution. You can find the appropriate method in:

private void RetractFarmSolution(SPSolution solution)

{

solution.Retract(DateTime.Now);

}

A timer job will be created to Retract the solution. You can specify the time to start retraction.

For removing solution only from a specified web applications, there is an overloaded method.

private void RetractFarmSolution(SPSolution solution, Collection<SPWebApplication> webApplications)

{

solution.Retract(DateTime.Now, webApplications);

}



References

http://msdn.microsoft.com/en-us/library/ee361616.aspx

http://msdn.microsoft.com/en-us/library/hh528516(v=office.14).aspx

Summary

In this article we have explored how to use the Server Object Model to retrieve Sandboxed & Farm Solutions through code.

For reference please note that:

1. Sandboxed Solution is represented as SPUserSolution

2. Farm Solution is represented as SPFarmSolution

Posted in C# | Leave a Comment »

SharePoint 2010 – How Alerts works?

Posted by Editor on April 12, 2013

In this article we can explore the underlying infrastructure of SharePoint Alerts. Let us analyze step by step what is happening in the background when we create an alert, alert is triggered, email is sent etc.

What are Alerts?

SharePoint provides an excellent feature which notifies the users on changes of item/library.

Uses can set alerts on:

· Library / List

· Document / Item

You can set alerts through the SharePoint user interface as shown below:

clip_image002

In order to see the above button, you need to set your Email Server in Central Administration > System Settings > Configure outgoing e-mail settings.

clip_image004

clip_image006

For receiving the emails triggered you can use an SharePoint Email Notification Tool like smtp4dev.

Create Alert

Now you are ready to create an alert & we can examine what happens in the database.

clip_image008

Open the database & you can see the following recode in ImmedSubscriptions table.

clip_image010

You can see that the ListId column is assigned with List GUID.

The table structure follows:

clip_image011

clip_image006[1]

You can see database server & name through Central Administration > Manage content databases link.

If you have created a Summary Alert (daily or weekly) you can see the record was created inside SchedSubscriptions table.

The structure of SchedSubscriptions table.

clip_image012


Timer Job

Timer Jobs are responsible for building the Alert using template & sending the Emails. We can see the timer job status through Central Administration > Monitoring > Check job status link.

clip_image014

Scrolling down, you can see the Timer Job for Immediate Alert.

clip_image016

You can see the Status of last execution there. In my case it is succeeded. Click on the link to see the settings as shown below:

clip_image018

In the above case the Timer Job is scheduled to run every 5 minutes. You can try clicking the Run Now button to trigger execution.

Alert Templates

Timer Job creates the email content of through Alert Template file. We can modify the file, but copying & modifying is recommended. We can define template in the list & library level.

The Alert template can be found in 14 hive > TEMPLATE > XML folder.

clip_image020

By default there are 2 templates – one for email & other for sms. The alerttemplates.xml file contains around 10 thousand lines.

We can change the alert template through PowerShell & STSADM commands.

References

http://bit.ly/10uiVpB

Summary

In this article we have explored the activities & tables involved while working with SharePoint Alerts.

Posted in C# | Leave a Comment »

What is Ensure User?

Posted by Editor on April 8, 2013

In this article we can explore a new command associated with Squadron > Explorer add-in.

What is Ensure User?

Ensure User is the command that invokes EnsureUser() method for the SPWeb objects specified.

Why we need to call it?

For each new user in a web site, a user record is added to the User Info table. For new SharePoint installations, when the users login to the site first time, there will be simultaneous addition of records to the above table & might result in SQL Server Throttling error.

A wise advice for the problem is to add the user explicitly to each web site before the opening SharePoint to public.

image

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

image

How to perform Ensure User?

Please download & Install the latest version of Squadron. After executing it in Farm Account mode you will receive the following screen.

image

Enter the URL in the top pane & click the Explorer item from left pane. In the appearing SharePoint Web Application view, select you web item.

image

Click on the Ensure User button visible in the screen. In the appearing dialog enter the user names in the format DOMAIN\User:

image

After entering the user names, click the Execute button in the bottom to continue. You will get the following message box after operation is completed.

image

This makes sure that the user is available in the UserInfo table for the particular web site. This will prevent the possible SQL Server Errors happening in SharePoint Installations with hundreds of users.

image

You can also invoke the Ensure User within the Web Application & Site Collection level. The same button will be enabled for those commands.

For Web Application item selection:

image

For Site Collection item selection:

image

On invoking the Ensure User command, all the Web items will be enumerated in the selection dialog. You can select the web items to be processed for.

image

Following is the code that performs the EnsureUser() method invoking.

foreach (string user in UsersText.Lines)
            {   
                if (string.IsNullOrEmpty(user))
                    continue;

                foreach (int i in WebList.CheckedIndices)
                {
                    SPWeb web = WebList.Items[i] as SPWeb;
                   
                    try
                    {
                        web.EnsureUser(user.Trim());

                        SquadronContext.WriteMessage("Success: " + web.ToString() + " " + user);
                    }
                    catch (Exception ex)
                    {
                        SquadronContext.WriteMessage("Failure: " + web.ToString() + " " + user + " " + ex.ToString());
                    }
                }
            }

References

http://bit.ly/10uiVpB

Summary

In this article we have explore the Ensure User command. There are more commands associated with the Explorer Add-in of Squadron – plus, they are context sensitive based on Site / Web / List / Item types.

Posted in C# | Leave a Comment »

Squadron – Invalid URL Exception & Solutions

Posted by Editor on April 1, 2013

While working with the Explorer Add-in, you might receive the following error:

Invalid URL!

image

Problem

The Web Application object cannot be created using the URL specified.

Solution

You can try the following solutions:

1. Open Central Administration & Ensure the URL is correct

Open Central Administration > Manage web applications link

image

2. Execute the application from a Machine within Farm Environment & using the Farm Account.

In the Farm Machine, you an use CMD.EXE > RUNAS command to start Squadron in Farm Account context.

image

You can also try the http://localhost url within the farm environment.

Example: runas /user:DOMAIN\USER Application.exe (You will be prompted for Password)

 

clip_image002

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

clip_image004

Posted in C# | Leave a Comment »

Squadron – Backup & Restore Permissions

Posted by Editor 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.

Posted in C# | Leave a Comment »

Squadron Exception >> Unable to find SPDeletedSite…

Posted by Editor 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 Editor 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 »

 
Follow

Get every new post delivered to your Inbox.

Join 261 other followers