Tuesday, September 17, 2013

SharePoint 2013: Moving Central Admin to a New Drive


Check out the whole SharePoint 2013 Solution Series
New Titles Added Weekly!


This post steps through the high level process of moving the Central Administration (Central Admin) web site to a different drive with all of the details screenshots available in my SharePoint 2013 Solution Series Guide.
By default, the Central Administration web site is created on the C: drive using the default inetpub web site location. Many times administrators would like all of the web sites to run on a different drive, such as E:, since C: is a System Drive. While creating Web Applications, you may specify the location; the creation of Central Admin does not give you that option. You can easily move Central Admin to a different drive following fairly easy steps. (The same steps are possible in SharePoint 2007 and SharePoint 2010.)
Basically all you need to do is Extend the Central Admin web application. In doing this you specify a new port and location for the web site. This is where you specify a location other than the C: drive. Then remove SharePoint from an IIS web site selecting the original Central Admin web application name.This removes the original web site from the C: drive. After this is completed, run the SharePoint 2013 Products Configuration Wizards such that the Central Admin port is updated.
 
That's it! In less than 10 main steps you can easily move Central Admin to a different drive and insure that there are no web applications running off of the C: system drive. Once again, the same steps are possible in SharePoint 2007 and SharePoint 2010 as well.
 
Get all of the exact steps, details, and screenshots in my SharePoint 2013 Solution Series guide:


Check out the whole SharePoint 2013 Solution Series
New Titles Added Weekly!


 
 

 



 

Thursday, September 12, 2013

SharePoint 2013: Preventing Users from Editing Their Profile

While it might be nice to have users keep their information up-to-date in their profile, many times companies and organizations like to keep Active Directory (AD) (or an employee database that may feed AD) as the main source for user information. Therefore, in SharePoint, they may not want the user population to be able to edit their profile.

Navigate to Central Administration and click on Manage Service Applications under the Application Management section:

 
On the Service Applications page, scroll down and click on the User Profile Service Application link:

 
 
The Manage Profile Service: User Profile Service Application page appears. On this page click on Manage User Permissions within the People section:

The Permissions for User Profile Service Application dialog appears.
 
 
Within the Permissions dialog, you may add users and change their permissions accordingly. Do disable editing of profiles, select the All Authenticated Users entries and then uncheck the Follow People and Edit Profile option:


You may disable the creation of personal sites (My Sites) as well as tags and notes usage here also. Click OK once the modifications are completed.
 
Guess what?? This doesn't work!
 
If Create Personal Site is checked, users may edit their profile regardless if the Follow People and Edit Profile is checked. So the only way you can turn this off is if you uncheck Create Personal Site as well as Follow People and Edit Profile.
 
 
 
 
 

Wednesday, September 11, 2013

SharePoint 2013: HTML Entity Codes in Rich Text List Columns

Recently I ran into a problem attempting to programatically replace characters within a rich text list column from a SharePoint 2010 workflow activity in SharePoint 2013. The replacement characters are identified by being placed in curly brackets (e.g. {ReplaceMe}). The code that used to run in SharePoint 2007 no longer did.

In investigating the stored string value of the list item, I noticed that the brackets were being replaced with ASCII-based HTML entity codes. Therefore the replace statement would never find {ReplaceMe} since it was in the retrieved string as {ReplaceMe}. Since there are possibly hundreds of workflows that already look for values based on the brackets, I needed to actually replace the brackets in what workflow was looking for with the HTML entity codes.

Lucky enough retrieving these values using the object model (SPList, SPQuery, etc.), seems to convert the string back to the friendly version as I also had an email console app that did a similiar find and replace from a rich text list field and that continued to work without any modifications.
However, it still worked because I was using HttpUtility.HtmlDecode when retrieving the value from the list item.


So basically, using the HttpUtility.HtmlDecode will prevent any mishaps but, just in case, I wanted to document the HTML Entity Codes that are used within SharePoint 2013 Rich Text Fields:

CharacterHTML Entity CodeName
{ { Left Curly Bracket
} } Right Curly Bracket
& & Ampersand
< &lt; Less Than
> &gt; Greater Than
: &#58; Colon
" &quot Double Quotes

Thursday, September 5, 2013

How To Create a WCF Web Service in SharePoint 2013


Check out the whole SharePoint 2013 Solution Series
New Titles Added Weekly!


Introduction
Many times you need to access SharePoint data from a web service. This could be for custom web parts, InfoPath Forms, BCS purposes, etc. When you need to access SharePoint data (e.g. list items, document information, etc.), the best method in SharePoint 2013 is to create a custom WCF web service that lives on your SharePoint farm.

Step 1 - Visual Studio 2012 Project
The first step is to open up Visual Studio 2012 in a SharePoint development environment and create a new project using the SharePoint Empty Project template.

Step 2 - Leverage the WCF Project Template
Your SharePoint project needs the WCF service components. It is easier to have them generated from a WCF project and copy them into your SharePoint WCF project. 

Step 3 - Copy the Service Classes to Your SharePoint WCF Project

Copy the IService1.cs and Service1.cs files that were generated in the WcfServiceLibrary project into your SharePoint WCF project. Once these files have been copied into your SharePoint WCF project, you may remove the WCF Service Library project from your solution.

Step 4 - Add References to Your SharePoint WCF Project
You need to add the System assembly references to your SharePoint WCF project. When you create an Empty SharePoint project, the Microsoft.SharePoint and  Microsoft.SharePoint.Client.ServerRuntime references are already in place. You no longer need to add these as you may have had done in previous versions of Visual Studio and/or SharePoint.

Step 5 - Define your Service and Data Contracts in the Service Interface
In your interface file (IService1.cs), remove the current operation contracts and define your own for your WCF service.
For example purposes, I needed to create a WCF Service for BCS and Search which requires a ReadItem method and a ReadList method. Therefore, in my ServiceContract, I created two OperationContracts - one for each.

The implementation of these methods will read list items in a SharePoint Calendar list and return the data within an object. In my example, the object is an EventItem which is a custom class. Therefore, in my DataContract, I needed to define the EventItem class.

Step 6 - Prep the Service Class
The service class (Service1.cs) implements the operations that you defined in the interface, however, there are some preparations that need to be performed first. This includes attributes and using statements.

Step 7 - Implement the Service Methods
In your Service class, add the implementation of the methods that you previously defined within your service interface.For my BCS example, I needed to implement a ReadItem and a ReadList method.

Step 8 - Create the SharePoint Service Registration File
The moving parts of the WCF service are now completed, however, in order for the service to be deployed and workable in SharePoint, the .svc file needs to be created. The .svc file contains the WCF service information as well as the referenced assembly (.dll) that is generated when you build the solution. The assembly information is added into the registration file upon the build and deployment of your SharePoint WCF Service.

Web services in SharePoint live in the ISAPI folder on each web-front-end and are referenced using  /_vti_bin/ within a SharePoint URL. Therefore, you must create an ISAPI folder in your project and then create the registration file within the ISAPI folder.
Next, you need to create the registration file within the ISAPI folder.
 
Step 9 - Activate Token Replacements for Service Files
The code that you pasted into the .svc file contains the assembly full name token ($SharePoint.Project.AssemblyFullName$). Visual Studio replaces this with the assembly from your project during build and deployment. However, you must instruct Visual Studio to perform this in .svc files. This requires a modification to the actual project file of your SharePoint WCF service.

Step 10 - Deploy Your SharePoint WCF Service
Right-click your solution and select Deploy. Visual Studio builds your solution, generates an assembly, updates the .svc file, creates a WSP file for deployment to stage/production, and deploys your SharePoint WCF service to your development SharePoint environment.

Step 11 - Test Your SharePoint WCF in SharePoint
Once your solution has been deployed, you may access the WCF service in SharePoint using the SharePoint root URL along with the path to the service:

http://<<sharepoint root>>/_vti_bin/Service.svc

To fully test the service you need to call it from a client application or use the svcutil.exe tool to invoke the service methods to insure data is being returned.

 
Using Your WCF Service in BCS
When creating an external content type using a SharePoint WCF Service, you need to enter and select the proper selections. This section shows examples of these settings:

Service Metadata URL

http://<<sharepoint root>/_vti_bin/Service.svc/mex?wsdl

Metadata Connection Mode

WSDL


Service EndPoint URL

http://<<sharepoint root>>/_vti_bin/Service.svc

Conclusion
In just a handful of steps you can easily create a WCF Service in SharePoint that serves up SharePoint data. Using the WCF Service Library template as a guide and an empty SharePoint project, Visual Studio 2012 provides the tools and functionality to generate and deploy a SharePoint WCF service.


Get all of the details with supporting screenshots in this low priced Kindle guide:


Check out the whole SharePoint 2013 Solution Series
New Titles Added Weekly!

Thanks for your support!