SharePoint Experts, Information Architects, Expert Witness
SICG provides a broad array of business and technology consulting from architecture to design to deployment of global systems with a focus on surfacing data in the enterprise. We focus on the "How", not just the possible. Contact me direct: firstname.lastname@example.org or call 704-873-8846 x704.
Search This Blog
Wednesday, August 24, 2011
SharePoint Logout with UAG
Unified Access Gateway (UAG) and SharePoint Logout
If you are working with UAG and SharePoint, you might find that there are some oddities in the Log out process. Specifically, you might see some of the following symptoms:
·Trying to Login as a Different user displays a ‘not found’ UAG page
·Logout of SharePoint leaves user logged in to UAG
·Logout of SharePoint leaves user logged in to SharePoint
·Logout redirects to a bad page
Note: This has also been found to be an issue using ISA and Forefront.
There are a few ways to deal with the issue but bear in mind, that you must use the SharePoint logout process to ensure that users are indeed logged out. You can use a combination of the following solutions to customize a way to deal with it on your site.
The first issue you have to deal with is the menu; that is the menu where users can either logout or login as a different user. This is a control that can be located under c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\ControlTemplates\Welcome.ascx. You can edit this file directly (make a backup first) or you can create a feature to overlay this file in a SharePoint farm so that you do not have to worry about keeping the servers in sync (see below).
Within this control, you have a few options:
1)You can simply delete the ‘login as a different user’ option – this section of code looks like this:
3)You can remove both options completely and a) replace it with your own custom link or b) integrate a logout button in your Master Page.
Creating a Welcome replacement feature:
The easiest way to deploy your custom welcome control is to create a simple feature that copies the file into a custom folder under CONTROLTEMPLATES as well as deploy a new master page that has the control path adjusted:
NOTE: DO NOT attempt to overwrite the original Welcome.ascx file using a feature (this is possible since the Control Templates folder can be selected) since it will erase the original file. The problem is that you cannot copy or backup the file via the feature and when the feature is removed, the ASCX file will be removed with it.
The Custom Logout Page:
To ensure the user is logged out properly, it is necessary to run the SharePoint controls that kill the cookie, etc. This is easily done by making a copy of the signout.aspx file located in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Layouts\.
In that same folder, you should create a new folder called CustomPages – this is where the custom logout page should be placed. In this way, you can always reference the file with the relative URL of /_layouts/CustomPages.
<!-- This is put in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\CustomPages -->
Creating the Custom Logout URL Feature:
Depending on your environment or governance, you may not be able to alter SharePoint’s default files so you can get around this using a feature.
Create a new Empty SharePoint project in Visual Studio called ChangeURLSignoutFeature (you can call it whatever you like if you don’t like that name).
When prompted, select the site you wish to deploy to and leave the Sandbox Solution selected (do not deploy as a farm solution!) and click Finish.
When the project opens, right click on the Features folder and from the menu, select Add Feature. When the feature is created it will have the default name of “Feature1”, rename it to ChgSOURLFeature (again, you can use a different name if desired) then update the feature title and description.
Right click on the Feature and select Add Event Receiver. This will create an empty event handler (code commented out) using the same name as the feature itself.
Code the Event Handler with the following – this will be triggered on Activate and Deactivate of the feature:
if (!webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Signout, null))
thrownewSPException("Could not restore default signout page");
Compile the project and assuming all is well with the compile, try deploying it to your site. If you do this from Visual Studio, it will automatically activate. If you use the WSP to install (as you would in a production site) using the STSADM –o AddSolution command, you must navigate to the site, select Site Actions > Site Settings then click Site Features. When the list of features opens, you can activate the feature.
You can then try the logout to verify it is running your custom page.