Thursday, December 13, 2012

Share Site Columns across site collections - Content Type Hub

 

The kind of structure we have for our SharePoint applications has now spread over to multiple web applications and multiple site collections in those web applications.  We have around 30 seperate site collections in total for a single organisation.  We do have several site - sub sites existing in those but in many cases they are completely seperate. 

However, since all of this is for one organisation only, we do have some data required to be used in all like State, Organisation Name, Branch name, Owners etc.  We needed to be able to share the data for these columns across site collections.  For this one approach is to create Managed Metadata service, create term sets there and use them in lists as managed metadata columns.  But, this does not allow us to control our master lists via transactions. 

That is why we decided to get it done via Content Type Hub.  You create a seperate site collection wherein you create all such columns which need to be shared across the farm.  You can then publish this site collection to a managed metadata service.  This allows us to use those columns in any site on the farm.  Follow the below steps for how to create a content type hub:


1.       Create a new site collection from blank site template

2.       go to Site Settings -> site collection features and activate the feature for 'Content type syndication hub'
 
3.       Create Site Column for say ‘State’.  Enter it as a choice column.  Enter the values for the same. 

4.       Create as many columns as you need for your content type. 

5.       Create Content type.  In this case the base content type needs to be list content type- item.  Further add the site columns to the content type. 

6.       Create Managed Metadata Service. 

7.       Go to Central Admin, Application Management, Manage Service Applications.

8.       Create New Managed Metadata service.  Towards the end, in the section Content Type Hub, enter the url of the site created above.  Make sure you do not enter the complete url with the page name.  Just enter the site url.

  

 
9.       Once you set this hub, you will be able to change it only using Powershell command.

10.   Select the Managed Metadata service and click on properties in the ribbon. Make sure the  top two options are not selected.   

 

11.   Go back to the content type you created.  Site actions, site settings, content types, select the content type in question and select ‘Manage publishing for this content type’.

12.   In case you receive any error on this step, check for the url entered while creating managed metadata service.

13.   In case any change is made in the content type, it will need to be published again. 

14.   Create another site collection where you want to use the site columns. 

15.   Create a list, select existing site column; you will see a list of all the site columns created in the hub. 

Tuesday, May 8, 2012

Call Javascript from SharePoint Asp Menu

We had a particular situation where we needed to open a dialog box on the click of a menu item in the top SharePoint navigation.  If we have a normal link on the master page or layout page, we can call javascript like below:
javascript:OpenDialog('/Pages/Contact.aspx');
But, when we try to enter the same in the SharePoint navigation, it gives us an error. 

In order to counter this, we found out a workaround.  There are some separate pages for quick launch and top nav as below:

1. Quick Launch:  http://'site url'/_layouts/quiklnch.aspx
2. Top link bar:  http://'site url'/_layouts/topnav.aspx


Here your can enter any kind of url.  We were able to open the page from our site in a dialog box.  The OpenDialog function we wrote in a js file and referenced in the master page. 






Sunday, April 22, 2012

Fusion Charts for SharePoint 2010

Recently we had a requirement to create highly visual Dashboard in SharePoint to be implemented in very less time.  We used one of the charting tools known as Fusion Charts for the same.  The best part about these charts is they can be used with any version of SharePoint - WSS, MOSS 2007 and all versions on SharePoint 2010. 

The various benefits of the tool are:
  1. It can be used with different data sources - SharePoint lists, Views, CSV, SQL, Excel. 
  2. It is easy to use without any code.
  3. It has an entirely visual interface and charts can be created without any code.
  4. It supports Filtering, Grouping and Drill downs.
  5. The most important thing is the look and feel.  These charts are highly animated and the business users and customers can be wowed by Dashboards built using this tool.

Tuesday, April 17, 2012

Hide 'Home' link on SharePoint 2010 top menu

In order to hide the 'Home' link on the top menu in SharePoint 2010, please follow the below steps:

1. Open you site master page in SharePoint designer.
2. Locate and delete the below from the master page:
'SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource"
Id="topNavigationDelegate"'
'Template_Controls'
'/Template_Controls'
'/SharePoint:DelegateControl'

This is required to delete the existing delegate wrapper from the master page.

3. After that change your data source to the below code:

'asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="CombinedNavSiteMapProvider"
id="topSiteMap"
runat="server"/'

Now you will not see the default home link for the site. You will see only links set up in your navigation.

Monday, March 19, 2012

How to create a SharePoint menu from xml

We had a requirement wherein we wanted to create a SharePoint menu with 4 level of menus. We used an xml source for the same for the same.

Step1: Create a document library and add a new xml document from SharePoint designer.

Step 2: Open your master page and add a new datasource. To add a new datasource, click on the above ribbon and select DataSource - select your xml file. It will include the below code in your master page

'SharePoint:SPXmlDataSource runat="server" id="SPXmlDataSource1"' 'DataFileParameters' 'asp:Parameter Name="FileName" DefaultValue="main_menu.xml"/' 'asp:Parameter Name="FilePath" DefaultValue="Menu"/' '/DataFileParameters' '/SharePoint:SPXmlDataSource'

Step 3: Make the below changes in your AspMenu control:

'SharePoint:AspMenu
ID="SPSiteMapProvider1"
Runat="server"
EnableViewState="false"
DataSourceID="SPXmlDataSource1"
UseSimpleRendering="true"
UseSeparateCss="false"
Orientation="Horizontal"
StaticDisplayLevels="2"
MaximumDynamicDisplayLevels="4"
SkipLinkText=""
CssClass="Custom-tn"'
'DataBindings'
'asp:menuitembinding NavigateUrlField="url"
TextField="text" /' '/DataBindings'
'/SharePoint:AspMenu'


Notice two things above - DataSourceID is the same as the XML datasource.
Also, we have included something as DataBindings to get the exact value from the xml. This is going to change depending on the text field in the xml you are using.

In case you need the same setting for your sub sites as well, you will need to create another master page. Simply copy everything in your master page, create a new one and make the below change.

In the section - SPXMLDataSource change the 'DefaultValue' to below:

http://210.212.92.197:1000/Menu. This is the exact path of the document library of your home site.

Thursday, March 1, 2012

How to setup FBA Claims in SharePoint 2010 with A D Membership Provider

In this post I am going to explain how to set up a SharePoint 2010 claims base authentication from Active Directory Membership Provider.

There are several posts which follow certain config changes and some other entries to achieve the same. But, after following atleast 10 of them, I was still stuck. I have finally figured out the sequence of events to be done to achieve the desired output.

Step1: Create web application with Claims Authentication Mode. Go to Central Admin, Create new web application. Choose Claims Based Authentication.
Now, here when you reach the identity providers section, you can also choose windows also as your identity provider along with forms. For testing purposes, I started with taking both windows and forms as my provider.
Enter the name of your membership provider. I am taking the name as 'admember'.

Step2: Next you need to make changes in three web.config entries:
1. Web config of Central Admin.
2. Web config of your newly created web application.
3. Web config of STS (Security Token Service) application.

Open the web config of Central Admin and add the below entries:
First the connection string,
'connectionStrings'
'add name="adconn"'
'connectionString="LDAP://logimindz.net/CN=Users,DC=logimindz,DC=net"/
/connectionStrings'

Here, connecton strin represents the below:
LDAP://abc.com/cn=users,dc=abc,dc=com/ This will change according to your organisation.

Then the provider
add name="admembers"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="adconn"
enableSearchMethods="true"
attributeMapUsername="sAMAccountName" /

Make sure the connection string is placed outside the 'System.Web' section and the 'provider' is placed within the System.web section.

Make sure the provider admembers is the default provider against your membership tag.

Open the web config of the web application

First the connection string:
connectionstrings>
add name="adconn" connectionString="LDAP://logimindz.net/CN=Users,DC=logimindz,DC=net"/
/connectionStrings

Next search the word 'membership' in your config file. You will find there is already a membership declared with the name 'i'. Add the below to the membership tag.

add name="admembers"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="adconn"
enableSearchMethods="true"
attributeMapUsername="sAMAccountName" /

Make sure the provider i is the default provider against your membership tag.

Save and close the web.config.

Open the web.config of your STS:

You can do this in two ways - Go to inetmgr - Sites - Sharepoint web services - SecurityTokenServiceApplication. Click on explore and open the web.config.
Or go to c:/program files/common files/ microsoft shared/ web server extensions/web services/security token and open the web.config

First add the connection string:
connectionStrings>
add name="adconn" connectionString="LDAP://logimindz.net/CN=Users,DC=logimindz,DC=net"/
/connectionStrings

Then add the provider entry:
add name="admembers"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="adconn"
enableSearchMethods="true"
attributeMapUsername="sAMAccountName" /

You will probably need to add the 'System.Web' tag also. The below tags will need to be added:

'System.Web'
'Membership'
'Providers'
'Add name='

Next do an iisreset.

Step3: Wire up provider to the web application

1. Go to CA - Web application management page, select your web application and choose 'Authentication Providers' from the ribbon.
2. Choose 'Default' and go the 'Identity Providers' section.
3. Select 'Enable ASP.net membership and role provider' and type the name of your provider in the text box.

Step4: Add users for the web application

1. Select your web application.
2. Hit User policy in the ribbon above.
3. Hit the browse users button in the people picker web part.
4. Notice the dialog box is changed, there are sections like 'Active Directory', 'All Users', 'Form Auth', 'Organization'.
5. Type in an AD user name and search.
6. There should be two results for the same user - one through NTLM and one through form auth. Select the user from form auth result and hit finish.

Step5: Create top level site in the web application

Now you can create the desired top level site in the web application. You will get two options while trying to log in - Windows and Form based authentication.

You can either use both or disable windows auth from the web application settings to get only form based login.

Wednesday, December 28, 2011

Adding metadata properties in advanced search

While we were working with search, we created hiererchy, we created managed metadata properties and added refinements to our search on basis of those managed metadata properties.
Now, we want the same metadata properties in our advanced search. How to customise the advanced search webpart to view our metadata properties.

1. Go to the advanced search page, click on edit page
2. Click on 'Edit web part' on the Advance search box web part.
3. Expand the properties section.
4. Copy the xml in the properties section, paste to xml editor or visual studio.
5. Collapse all nodes.The last two nodes are the ones which we have to change.
6. First is the propertydefs node.
7. Copy and paste the below line in the property defs tag -
PropertyDef Name="Department" DataType="text" DisplayName="Department"
8. Now go to the 'ResultTypes' node and paste the below line in each section - PropertyRef Name="Department"
9. This line should go in all the sub sections of 'ResultTypes'.
10. Copy this xml and paste in the properties section of the web part.
11. Click on OK and come out of edit.

You will see the property as below in the advanced search section: