Enumerating All SPWebs In SPFarm.Local Into Strongly Typed Collection

So when enumerating the SPWebs within a SPFarm to build a strongly typed SPWeb collection for whatever purpose your enumeration might look like this:

[csharp]

public static List WebsPreppedForIteration()
{
var collection = new List();
foreach (SPSite x in SPFarm.Local.Services.OfType().SelectMany
(svc => ((svc).WebApplications.Where
(webApp => !webApp.Properties.ContainsKey(“Microsoft.Office.Server.SharedResourceProvider”)).SelectMany
(webApp => webApp.Sites.Cast()))).Where
(x => !Equals(x.RootWeb.Title, “Central Administration”)))
{
collection.AddRange(x.RootWeb.Webs.Cast());
}
return collection;
}

[/csharp]

I saw this in a code review today. The part I am wondering about is the SPWebApplication property bag to query the key for WCAM as opposed to do a clunky string SPWeb.Title comparison. Putting the keys out to standard output hasn’t yielded anything particularly evident, and I’m getting frustrated with the under-the-hood, unnecessary foreach loop with a fancy shirt on (the second LINQ query against the Title property(,

Does anyone know the key for WCAM?

Share

InvalidOperationException With WCF Service In SharePoint 2010

At a client today we were focusing on moving a bunch of custom, in-house deliverables to a SP 2010 RC environment so that we could test all the moving pieces required for their environment to function. About half way through all successful, uneventful testing, we finally hit an error when examining a WCF service hosted in SharePoint. The particular error message was:

[InvalidOperationException: Operation is not valid due to the current state of the object.] Microsoft.SharePoint.ApplicationRuntime.SPLayoutsMappedFile.MapLayoutsVirtualPath(String virtualPath)

If you run into this error, its pretty easy to fix. In the ServiceBehaviorAttribute of your service class, ensure the following is present:
[csharp]
[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
[/csharp]
As well in the SharePoint web.config, in the serviceHostingEnvironment make sure the aspNetCompatibilityEnabled attribute is set to true.

Share

ForeFront TMG and Active FTP Issues

While working with a client today, I was informed that they were having issues with a recently converted ISA to TMG instance, using the latest release of TMG. Particularly, the issue was that Active FTP just wasn’t plain working when used from a SharePoint financial application that is pretty heavily treaded.

Now for folks who aren’t accustomed to the difference between Active and Passive FTP, when using active mode the client machine will connect to a random unprivileged port to the FTP server’s command port, port 21. Following, the client will start listening to that port and sends the FTP commands in respect of the aforementioned port. The server will then connect back to the client’s specified data port from its local data port, which is port 20.

Now, there are some additional steps required when using ForeFront TMG in order to get Active FTP working, which in ISA 2006 was accomplished by merely unchecking the read-only checkbox on the rule and configuring Windows Firewall. In TMG the process requires additional steps, since it is also required to not only uncheck the read-only checkbox on Configure FTP, but you also have to right click the rule, go to System – > Application Filters and check the Allow active FTP access in the FTP Filter.

Share