Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting UK – HostForLIFE.eu :: How to Find The Installed SharePoint 2016 Edition Via C#
You can easily get the SharePoint Build Number via C# as shown below.
1 2 3 4 5 6 7 |
public string Get_SPVersion() { try { return SPFarm.Local.BuildVersion.ToString(); } catch (Exception) { throw; } } |
But, have you ever tried to detect the SharePoint Edition via C#? Well, regardless of the answer, detecting the SharePoint Edition via C# is not just a line of code as Build Number. To detect the SharePoint 2016 Edition, it will require knowing the corresponding SKU. Stock Keeping Unit (SKU) is a unique set of characters’ identification code for a particular product/service. Read more at SKU.
Get SharePoint 2016 Edition via C#
Based on the installed product SKU, you can detect the corresponding SharePoint 2016 Edition programmatically, as the following.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
public string Get_SPEdition() { try { string edition = ""; SPSecurity.RunWithElevatedPrivileges(delegate() { var editionguid = SPFarm.Local.Products; foreach(var item in editionguid) { switch (item.ToString().ToUpper()) { // SharePoint 2016 case "5DB351B8-C548-4C3C-BFD1-82308C9A519B": edition = "SharePoint Server 2016 Trail."; break; case "4F593424-7178-467A-B612-D02D85C56940": edition = "SharePoint Server 2016 Standard."; break; case "716578D2-2029-4FF2-8053-637391A7E683": edition = "SharePoint Server 2016 Enterprise."; break; default: edition = "The SharePoint Edition can't be determined."; break; } } }); return edition; } catch (Exception) { return "An error occurred! Make sure that\r\n- The SharePoint is installed"; } } |
In case, it’s
1 2 3 |
5DB351B8-C548-4C3C-BFD1-82308C9A519B, the installed SharePoint Edition is SharePoint 2016 Trial. 4F593424-7178-467A-B612-D02D85C56940, the installed SharePoint Edition is SharePoint 2016 Standard. 716578D2-2029-4FF2-8053-637391A7E683, the installed SharePoint Edition is SharePoint 2016 Enterprise. |
Output
(Test1) You have SharePoint 2016 installed. The result should look like –
(Test2) You don’t have SharePoint 2016 installed but you have other SharePoint version, the result should look like –
(Test3) You don’t have any SharePoint version installed, the result should look like –
Print article | This entry was posted by Peter on November 9, 2017 at 7:57 am, and is filed under European SharePoint Server 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |