Tuesday, February 28, 2012

How to detect SharePoint platform is MOSS or WSS?

SharePoint platform wasn't show special thing to determine MOSS or WSS is running currently. But we can check the feature in feature collection to detect the default feature for MOSS. When we install MOSS, there are 2 features as default in MOSS flatform:OssNaviation and Publishing. Just check these feature, the code snippet look like:



 private bool CheckMossOrWss()
        {
            bool isMOSS = false;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPFeatureDefinitionCollection features = SPContext.Current.Site.WebApplication.Farm.FeatureDefinitions;
                SPFeatureDefinition docSetfea = features.FirstOrDefault(f => (f.DisplayName == "DocSet" || f.DisplayName == "Publishing"));
                 
                isMOSS = (docSetfea != null);
           
            });
            return isMOSS;
        }


Hope this help.

No comments: