I recently had a case where I needed to programmatically determine which zone in my SharePoint 2010 web application had forms-based authentication enabled and then return the public/default URL of that zone.
The reason was a custom application page in SharePoint was sending out emails with links back to SharePoint, and in this case those links needed to always redirect users to the FBA-enabled zone so we send them through a custom login/registration process we’d configured on that zone. Administrators using this custom application page might be accessing the page from one of the non-FBA-enabled zones on the web application – hence the reason to programmatically determine the correct URL to include in the email.
Here’s the code I ended up using to find the URL:
public static string GetFbaZoneUrl(SPWeb web)
string url = null;
foreach (var zone in webApp.IisSettings.Keys)
var settings = webApp.IisSettings[zone];
var fbaProvider = webApp.IisSettings[zone].FormsClaimsAuthenticationProvider;
if (fbaProvider != null)
// We found the zone on the web app where FBA is enabled.
// This is the zone whose URL we want.
SPAlternateUrl fbaUrl = webApp.AlternateUrls.GetResponseUrl(zone, false);
if (fbaUrl != null)
url = fbaUrl.IncomingUrl;
if (url != null && !url.EndsWith("/"))
url += "/";
As you can see in the code, I break from the loop after finding the first FBA-enabled zone in my web application because I know there will never be more than one in my case. If for some reason you have multiple zones configured to use FBA, you could modify this code slightly to return a list of all FBA URLs or filter down to the one(s) you want by some criteria (such as the membership/role provider names). The AlternateUrls property of the SPWebApplication object allows me to grab the response URL (i.e. the default URL) for a given zone.
Wow, I can’t believe it’s already 2013!! This past year went by WAY faster than I was expecting. I’m going to try to start the year off right… by posting my goals and predictions for the year on my blog like all good bloggers.
Goals for 2013
- Get some awesome on-demand training courses posted online.
- Speak at a conference or two.
- More blog posts and more SharePoint Pro Magazine articles (fell behind on this in 2012 due to the book).
Predictions for 2013
- More small and mid-size companies will move to Office 365 and “the cloud.”
- More mobile apps will be developed that integrate with SharePoint and leverage its capabilities.
- We’ll see apps being developed and sold in the SharePoint 2013 app store.
- We’ll see an increase in demand for SharePoint training because of a broader developer base (thanks in part to the app store).
- No matter how cool SharePoint 2013 is, SharePoint will continue to be occasionally frustrating to work with… just as it always has been.
Here’s to a great 2013!
The presentation I just gave at SharePoint Saturday in Denver on November 12 has been posted and is available on my Presentations page.
Thanks again to everyone who attended! It was a great turnout, and I had a great time!
I’m not a big fan of New Year’s resolutions and generally don’t bother making them, but for some reason I feel differently in 2011. Maybe now that I’ve been blogging for a while I just feel compelled to join all the other folks writing about their own resolutions. I don’t really know.
At any rate, here are the ones I’m making for 2011:
1. Lose weight
Yeah, I know, everybody makes this one (and then usually doesn’t keep it). But I’ve got a Nintendo Wii and got the Wii Fit for Christmas, and it seems to think I need to lose 21 pounds. There’s just something unsettling about a video game telling you you’re overweight, so I’ve got to do something about it.
2. Grow my business
As the owner of a technology business, it only makes sense to keep growing the company and getting more clients. In the past Incline Technical Group has focused solely on consulting, particularly in the areas of Silverlight and SharePoint because they’re our core strengths.
But this year we’re adding something new. We’re going to try offering pre-packaged training courses. Like our consulting work, the focus will be primarily Silverlight and SharePoint, at least initially. After doing a couple of user group presentations and a Silverlight “how to” video last year, I realized people out there are thirsty for knowledge, especially when it’s useful and tackles real-world problems they hit every day.
So that’s a goal of ours for this year. We’ll work on putting some really great classes together that cover real-world scenarios and get those offered ASAP. Everything will probably be done over the Web initially, but if the interest is there, we’ll expand into classroom training as well.
3. Write more articles
I fell short of my goal last year for the number of articles I wrote and had published. This year I’d like to do at least three or four. Maybe two on SharePoint for SharePointProConnections magazine and an article or two on Silverlight for DevProConnections Magazine. We’ll see how things go.
Here’s to a prosperous 2011 for us all!