Tuesday 20 July 2010

SharePoint 2010 membership provider/Claims based authentication

What is Claims based authentication?
Allows SharePoint to communicate with external membership providers over open communication standards to authenticate a user. The membership provide determines if the user is valid. A token either saying the user is valid or invalid is returned. More info
Authorisation is handled by SharePoint or the logic can be applied by external membership providers.
Forms Based Authentication (FBA) works with your membership provider to give users access off a provide such as LDAP providers like Active Directory (AD).
You can also setup Windows Authentication in the "Identity Provider" where you use either NTLM or Kerbros as well as other ASP.NET providers.
The SecurityTokenService (STS) Application ensures claims tokens are being passed correctly between the provider and SharePoint (Our SPSite). STS allows for multiple providers plugged in our site. STS is setup in the web.config. More info.
Tip: Sign in Url - when setting up FBA, you can use a custom page to add business logic, for instance I assign rights/permissions when a user comes from a trusted 3rd party. More info.
Tip: FBA doesn't have to use claims based authentication as in MOSS. If you have AD but need to provide Internet access then Claims based adds no value. More info.
NTLM vs Kerbros: NTLM stands for NT Lan Manager. Microsoft's challenge response authentication protocol. Kerbros is an open standard authentication protocol, it is more secure in that it is encrypted and token are used to validate parties in the communication process. Kerbros requires ADFS.  Kerbros is therefore more secure however you do need to have a network that supports Kerbrose for it to work. Kerbros is more chatty and introduces more points of failure. NTML is more efficient. Depending on usage such as Internet it will determine the protocol.  I tend to lean towards Kerbros in larger SharePoint implementations if the network supports.  Internet scenarios don't expose ADFS to the Internet so Kerbros is not an option.

More Info:
Setting up SQL claims based FBA

Updated: 2014-02-27
Setting up ADFS2.0
Configure an Authentication Provider for a Web App to use ADFS

http://www.sharepointpals.com/post/Creating-an-ADFS20-TrustedIdentityTokenIssuer-using-PowerShell-in-SharePoint-2013
http://www.sharepointpals.com/post/How-to-Add-more-than-One-SharePoint-2013-WebApplication-to-a-SPTrustedIdentityTokenIssuer-on-ADFS-using-PowerShell

Thursday 15 July 2010

Deploying resources using features

Overview: Feature deployment has changed in SP2010 from MOSS. In MOSS we added files to the 12 hive and deployed them via a feature. In SP2010 the feature is package slightly differently and is marginally easier to create using VS2010 because of the tools. I have VS2010 and the CKSDev tools installed.

Steps to add an xslt file to your style library using a feature in SP2010:
1.> In VS2010 create a new Element;
2.> Under the element add and xslt, change the "Deployment Type" property;
3.> Move the elements to "Items in the Feature" default is "Items in the Solution";
4.> Modify the elements.xml file;

5.> Ensure the itemStyleCustom.xsl exists in the Xsl Style library.

Wednesday 14 July 2010

SP2010 CQWP customisation

Overview: Content Query Web Part (CQWP) in SP2010 is similar to in MOSS. This post walks thru using the CQWP to display a custom list and custom columns while outputting custom html via a custom xslt.
CQWP (need the publishing feature enabled, this creates the styles library and add the CQWP) by default uses the xslt /Style Library/XSL Style Sheets/ItemStyle.xsl.

Steps:
  1. Don't write over ItemStyle.xsl as this si supplied by SP2010 OOTB. Rather create a new xslt and put it into the styles library. Build up the xslt, I based my file on the itemstyle.xsl file, see rules for getting the output you are looking for using How to: Customize XSL for the Content By Query Web Part
  2. Custom xslt formatting, I always add the following code in case I want to see what the available fields are:
  3. Deploy the custom style sheet via a feature.
  4. Create a new Custom list called "Pets" and add columns for Title, Age & Status (choice):
  5. Edit your custom xslt to display for "Pets" as shown below:
  6. Add a new CQWP to your page. Configure it to display items from your new list (Pets).
  7. Change the "Presentation" section, "Item Style" to Show "Pets". Apply the Changes:
  8. CQWP displays as:
  9. Edit the CQWP "Age" property to "Age"
  10. Edit the CQWP "Age" property to "Status"

    Tuesday 13 July 2010

    Audience Targeting in SP2010

    Overview from MS
    Technet User Profile Service Overview
    Audience targeting needs compilation so not useful when adding users on 1st login however, menu items can be targeted using SharePoint security groups.
    Audience targeting is part of SharePoint Standard edition.  SharePoint 2010 editions comparison.
    Update 5 Dec 2010 - The "Publishing feature" needs to be enabled on the site collection and site.  User Profile Service needs to be running.

    Setup Audience targeting on Global menu's.

    Overview: To use audience targeting you need to have at least SharePoint Server standard edition as you need the "Site Collection Publishing Feature" enabled. 

    In this walk thru I am adding a user to a SharePoint Group and allowing the group to see a menu option.  Also ensure audience targeting is enabled.
    Add the user to the Share Point group in my case I added the user "ReadOnlyUser" to SharePoint Security group "Extend Visitors".
    Edit the menu option to be only visible to the SharePoint group "Extend Visitors".
    Menu of normal user without the extra menu option.
    User that can see additional menu options

    Monday 12 July 2010

    Sharepoint 2010 Dialogs Framework

    Problem: Use the dialog framework to edit information on a SharePoint composite page.
    Hypothesis: Dialog framework can open existing pages and pass back values to the calling page. The pass back value can be more than just a simple parameter such as a string. You can return fairly complex flat objects. The example below, displays multiple addresses, allows the user to edit any of them via a modal dialog. and returns the updated address along with the id of the element address to change. To use the dialog framework modals you need SP context so use any of the client OM's or the server OM (i.e. you can't use html unless to load the SP context)
    In the parent page inside javascript add the following 2 functions
    function OpenDialogAdr(myurl) {
    var options = SP.UI.$create_DialogOptions();
    options.url = myurl;
    options.width = 200;
    options.height = 100;
    options.dialogReturnValueCallback = CloseCallback;
    var dialogSP = SP.UI.ModalDialog.showModalDialog(options);
    }
    var messageId;
    function CloseCallback(dialogResult, returnValue) {
    if (dialogResult === SP.UI.DialogResult.OK) {
    var adr = returnValue.adr;
    var id = returnValue.id
    $("#adr-sales-" + id).html(adr);
    }
    }


    Add a link with the appropriate js:
    Add the child page, that will return the new address and the id of the item to change.

    function onUpdate() {
    var adrs = document.getElementById('txtAdr').value;
    var ids = document.getElementById('txtId').value;
    var mydata = {
    adr: adrs,
    id: ids
    };
    SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, mydata);
    }
    function onCancel() {
    SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult
    }

    Resolution:
    The dialog framework is good for displaying additional information. It is similar in nature to using jQuery & the lightbox plug in.

    Resources:
    Working with SP2010 modal dialogs

    SharePoint 2010 UI/browser help urls

    Site settings url: http://...../_layouts/settings.aspx
    Determine CAML to create site columns  http://url/_vti_bin/owssvr.dll?Cmd=ExportList&List=listguid
    Remove web parts from a page http://url/_layouts/spcontnt.aspx?&url=page/_layouts/spcontnt.aspx?&url=page

    VS2010 deployment error Site Url property missing

    Overview: Each new developer on a project grabs the solutions/project files from TFS or VSS as in my case. When they try deploy the solution, they receive an error "Error occurred in the deployment step 'Recycle IIS Application pool': Cannot connect to the SharePoint Site: http://... Make sure that this is a valid URL and the SharePoint site is running on the local computer, ... Update the Site URL property on the project."
    Resolution: As the error suggest go to the project being deployed and ensure that you local development url is entered in the "Site URL" property. Obviously this setting should not be stored in source control as it will often differ per environment/developer.
    Visual Studio 2010 Project properties