Saturday, November 23, 2013

SharePoint Debug - Attach to Worker Process

Each SharePoint web application is run under a dedicated worker processes. Specially when it comes to DEV environments, when debugging a solution it's best to attach the code only to the target worker process. This avoids the hassle among the DEV team :) . It's pretty simple  to find the worker process related to the target web application. Follow these simple steps.


1) Start Command prompt with Administrator privileges
2) Navigate to C:\Windows\System32\inetsrv directory
3) Type in appcmd list wp


You get the list of  worker processes along with the web application which is running on it. Now in the Visual Studio IDE go to debugger and attach your code by selecting the appropriate worker process. Under the set of w3wp exe's you can pinpoint the exact one.


Saturday, October 26, 2013

Get-SPWebApplication is not recognised as the name of the cmdlet

When you try to execute SharePoint specific commands through PowerShell, might come across a message

"Get-SPWebApplication is not recognized as the name of the cmdlet ......"

The SP specific commands are not being recognized in PowerShell at this point. Adding a snap in would do the trick. Type the below command in your PowerShell  window.

Add-PSSnapin Microsoft.Sharepoint.Powershell

That's it. Provided that the rights in DB are there, you should be able to execute SharePoint based commands now.

Wednesday, September 25, 2013

When creating a Folder in Library - The server was unable to save the form at this time. Please try again [SP 2013]

In SharePoint server 2013 I tried to create a folder in side a document library and got this message.
"The server was unable to save the form at this time. Please try again".



 Was quite surprised at the beginning, but I kept getting this message over and over again. It seems like this is happening cause of a memory issue. At the time, the machine had only 8GB of RAM, which really should reach up to 16 GB of RAM for better performance.

Certain workarounds suggested that you restart the "SharePointSearch Host Controller Service" as a temporary solution to  free up some memory space. But it didn't do any good in my case.

Some were pointing out that the issue may have happened due to any add-on's installed in IE, But I didn't have any special add-on's in IE. Tried out the same using Chrome just to make sure I'm not missing anything. But still had no luck.

As a last resort did the famous iisreset assuming that anything held up will be released or refreshed. Nope, that didn't work either.

After some digging, I realized that Anonymous access to the site was disabled in IIS. Tried enabling it which was then followed by an iisreset and  ... Voila !! ... The Folder gets created !!   :)


So you have to Enable anonymous access at site level in IIS just to add folders to document libraries in SP2013 ??


....This somehow smells to me like a tiny 




Sunday, June 30, 2013

Connecting Server to an existing SharePoint Farm

Once, I had two separate SharePoint 2007 farms having its own server. I needed to change that to one farm with two servers. So I had to remove one farm from one server machine and connect it as a WFE to the existing farm in the other server. The first step was to remove one SharePoint farm.

1) You can use the following command to disconnect the database from SharePoint:

PSCONFIG.EXE -cmd configDB -disconnect








2) Then remove the SharePoint related DB's from SQL Server



3) Run the SharePoint configuration wizard. You get a message as below. Select "Yes".



4) In the configuration wizard, choose connect to existing server farm.



5) Select the database of the server which you need to connect and specify the DB access account to be used. Let the configuration happen.


Now go to the Central Admin. Select Operations. Select Servers in Farm. The new addition to the farm will be listed down.


Thursday, May 16, 2013

Creating a simple Event Receiver in SharePoint 2013

Create an empty SharePoint 2013 project in Visual Studio 2012. In the project, select add new item and select Event Receiver


Select the type of event receiver you need to add, and select the events you need to handle.



In this sample I'm trying to update a SharePoint list based on file changes happening to a separate SharePoint library. Basically, the list will act like a log. So we need to create the library and a list. Here, I have created the Department library to add and maintain documents and also created DocumentLog list to log the changes happening to the library. 

In the list I have three columns, Title, Action & DateAndTime in order to catalog the changes happening to the library.


[The created document library and list]

Back to the SharePoint project. Now go to the event receiver .cs file and you'll get a bunch of methods base on your selection during event receiver creation. Edit the code as below to implement the logic. Note that the ItemAdded method is used instead of the ItemAdding method.


public override void ItemAdded(SPItemEventProperties properties)
        {
            //base.ItemAdded(properties);
            using (SPWeb web = properties.OpenWeb())
            {
                try
                {
                    SPList list = web.Lists["DocumentLog"];
                    SPListItem newItem = list.Items.Add();
                    newItem["Title"] = properties.ListItem.Name;
                    newItem["DateAndTime"] = System.DateTime.Now;
                    newItem["Action"] = "Item Added";
                    newItem.Update();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }

public override void ItemUpdating(SPItemEventProperties properties)
        {
            //base.ItemUpdating(properties);
            using (SPWeb web = properties.OpenWeb())
            {
                try
                {
                    SPList list = web.Lists["DocumentLog"];
                    SPListItem newItem = list.Items.Add();
                    newItem["Title"] = properties.ListItem.Name;
                    newItem["DateAndTime"] = System.DateTime.Now;
                    newItem["Action"] = "Item Updated";
                    newItem.Update();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }

public override void ItemDeleting(SPItemEventProperties properties)
        {
            //base.ItemDeleting(properties);
            using (SPWeb web = properties.OpenWeb())
            {
                try
                {
                    SPList list = web.Lists["DocumentLog"];
                    SPListItem newItem = list.Items.Add();
                    newItem["Title"] = properties.ListItem.Name;
                    newItem["DateAndTime"] = System.DateTime.Now;
                    newItem["Action"] = "Item Deleted";
                    newItem.Update();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }


As I am targeting to add the event receiver only to the Department document library, the Elements.xml file requires a change.



 Note that I have commented out the setting which points to all document libraries, instead pointed to Department document library. The edited Elements.xml file is as below:


<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!--   <Receivers ListTemplateId="101"> -->
  <Receivers ListUrl="Department">

   <Receiver>
        <Name>DepartmentEventReceiverItemAdded</Name>
        <Type>ItemAdded</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>MySharePointProject.ListEventReceiver.DepartmentEventReceiver</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>

      <Receiver>
        <Name>ListEventReceiverItemUpdating</Name>
        <Type>ItemUpdating</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>MySharePointProject.ListEventReceiver.DepartmentEventReceiver</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
      <Receiver>
        <Name>ListEventReceiverItemDeleting</Name>
        <Type>ItemDeleting</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>MySharePointProject.ListEventReceiver.DepartmentEventReceiver</Class>
        <SequenceNumber>10000</SequenceNumber>
      </Receiver>
</Receivers>
</Elements>

Compile and deploy the solution to your site. Now you may play around with the library and observe the changes happening to the list.... :)

I have added a document, uploaded, added, modified the 3 docs and then deleted one of the docs respectively.


And here's what I get in the DocumentLog list.


Monday, May 6, 2013

Installing SharePoint 2007

Back in the day SharePoint 2007 was a hot topic for SharePoint newbies. Seems SP 2007 is still around in use and thought of blogging on key points to note on the installation and configuration.

Installation

Choose the installation type you want. Here I choose Advanced.



Choose the installation server type. I have selected "Complete"

Once the installation is done you will be prompted. Then MOSS will fire up the "SharePoint Products and Technologies Configuration Wizard"

1) System prompts the services that would be restarted before starting the wizard.

2) Server farm option: Creating New vs. Connecting to existing. I'm creating new


3) Specify database settings

4) Specify Central Admin Web App settings

5) Before the wizard starts, the user specified details are displayed

6) Then the wizard runs

7) Once the configuration wizard completes user is prompted of the end result.

8) Then, user is directed to the Central Admin. The "Services on Server" section indicates that services have to be configured



9) Note that you have to start the below services started in the image. Service settings are pretty straight forward.


Creating a new Shared Service Provider

1) Navigate to "Application Management" to create a new SSP. Select the link as shown below:

2) Select "New SSP"

3) In the "New Shared Service Provider" page, specify the web application for SSP and MySite

I have not created any web application yet. Hence I am creating two now. Select the links on the page in order to create new web applications. You will be directed to "Create New Web Application" page. Once it's done system directs you back to the Create SSP page.

3.1) Creating a web application

A web application can be easily created using the following steps. Specify the IIS website and port to be used for the new web application.


Provide the application pool name and the security account to be used.


Provide the database server name, database name & the authentication


Once the two applications are created the SSP can be created. 

4) On completing SSP creation you get a success message


Now in the Shared Services Administration page the SSP is displayed.


Sunday, April 14, 2013

SQL Server Configuration Manager - Cannot connect to the WMI Provider

Hi Folks,

I use SQL Server 2008 R2 on top of Windows Server 2008. Once I wanted to open up the SQL Server Configuration manager and ended up getting an error.

[Navigation]

It said "Cannot connect to the WMI Provider". The full error message is as below:


The operating system installed is 64 bit. The reason behind this issue is that the WMI Provider is removed. One way in which this could happen is, when you install an instance of the 32 bit version of SQL Server and an instance of the 64 bit version of  SQL Server in the same machine and then remove any of the instances afterwards. Both instances share the same WMI configuration file. When either of the instance are removed the WMI configuration file is removed.

As a workaround, type in the following command in the command prompt:

mofcomp "%programfiles(x86)%\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof "

Obviously, for this command to take effect the "sqlmgmproviderxpsp2up.mof file" should be available in the specified folder location :) 


And here's what you get when you execute the command


And there you have it ! Issue solved ! You could go back and view the configuration manager


Tuesday, March 19, 2013

Deploying People Search - SharePoint 2013

Now that we have configured the Search Service Application and created the search center next up is deploying people search. Here is how it goes.

Step 01 - Grant Access for an account to crawl the profile store

Navigate to Manage Service Applications in the Application Management. Click to highlight the Search Service Application. Click on the “Administrators” in the ribbon. When the dialog box pops up, add the intended user account.  Make sure the user has permissions to Retrieve People Data for Search Crawlers. Click "OK" when done.


                                                                                                                                                           
                                                               
Step 02 - Create crawl rule

Navigate to create a new crawl rule (Search service application > click Crawl Rule > New Crawl Rule).

The quick launch in the search service application page contains the link.

[search service application page quick launch]


[Manage Crawl Rules page]

Provide the path to the start address of user profile service application. The format would be sps3://<hostname> where host name is the URL for the web application in which the My Sites site collection is deployed.

Select “Include all items in this path”

In the authentication section you can either keep the default content access account or provide the one you gave administration permission. This basically depends on your requirement. In order to give authentication for the user which you prefer, select "Specify a different content access account"  and provide account name and password.

Note that the "Do not allow basic authentication check box is selected by default". This allows user credentials to be encrypted before sending, which is the preferred approach unless you are using SSL to encrypt traffic.




                                                                                                                                                                                                  
Step 03 – Remove the profile store URL from the default content source
Navigate to Manage Content Source page. Click on the default content source "Local SharePoint site" which was created by default.

In the Start address list, remove the URL for the profile store ( sps3://<hostname> ) and click "OK".

Step 04 – Create a content source to crawl the profile store

In the "Manage Content Sources" page click "New Content Source"
  • Type crawl name
  • Provide Start address in the format sps3://<hostname>
  • Select "Crawl everything under the hostname for each start address"
  • You can choose between the continuous and incremental crawl depending on your business requirement.
    •  If you are specifying the incremental crawl, setup a schedule for it.
  • Set the content source priority.
  • Click "OK"


Now the configuration is done ! User profile crawl is independent of the local sharepoint site crawl.

Make sure the user profile synchronization is setup (this is discussed in an earlier post.)

As for the first time, you can click on the drop down arrow of the newly create Profile Store content source, and start a full crawl.



Once the crawl is done you can go to the search center and try out the people search.


Sunday, March 17, 2013

Creating a Search Center - SharePoint 2013

This post is a walk through to create a search center in SharePoint 2013

Site creation Steps


In central admin go to Application Management and select Create site collections. Note that the search center is the top level site of a site collection.

In the Create Site Collection page:

  1. Select the web application
  2. Type in the Title & description
  3. Specify the URL for the search center
  4. In the template selection, click on the Enterprise tab

If you are using SharePoint foundation 2013, select Basic Center template else
If you are using SharePoint Server 2013, select Enterprise Search Center template













Specify the primary and secondary administrators


Specify the primary and secondary administrators
In the quota template, select "No Quota" (The search center site is not meant to be a data repository, hence no quota is needed)
Then Click “OK”

The site is created !!


Permissions

In order to grant permissions for the users navigate to the search center site, and click on the Settings gear on the top right hand corner of the site. Select "Shared with…"




In the shared with dialog click on "Invite people link"
When the "Share" dialog appears specify "NT Authority\authenticated users" under "Invite People to Read"
Set the permission level give "Read" access





Update My Site Settings

Go to the My site settings page (Navigation: Central Admin > Manage Service Applications > User Profile Service Application > Setup My Sites). 
In the preferred search center section provide the URL for the created search center. This will allow searches carried out from my site profile page to use the created search center.







SharePoint 2013 Search Service

I would like to blog a bit of what I know on the SharePoint 2013 search in the coming posts. Will start off by creating the search service. So here are the steps.

Step 01 - Creating the search service

In the central admin page, select “Manage Service Applications” under Application Management.
Then, in the Service Applications tab, select “New” drop down and select, “Search Service Application”























                                                                                                                                                                                                     
In the create dialog specify:
  1. Search Service application name
  2. Specify the service account
  3. Application pool for Search Admin Web Service
    • Specify the security account
  4. Application pool for Search Query and Site Settings Web service
    • Specify the security account 
Once the search service is created you will be able to see the search administration service along with the search service in the servises listing.






                                    
Step 02 - Configure

Specify the default content access account. By default the name you specify at search service creation is set as the content access account.






















Step 03 - Create Content Sources

When the Search service application is created a content source named “Local SharePoint sites” is created. This is configured to crawl all sites in the local farm.
To create a new content source in the Search service application, click content sources and select “New Content Source”.


Provide:
1 Content source name
2 content source type
3 addresses one below the other
4 Crawl schedule (Full and incremental)
5 content source priority























                                                                                                                        
                                              
Step 04 - Set Crawl rules
Crawl rules can be explicitly set for either exclude or include site from the crawl.