kamagra how much to take

Test Whether SharePoint Server Is a Database Server

The SPServer object is pretty useful when you are interrogating topological elements in your farm for different types of information. One of the thing that I test a lot when writing security / admin utilites for companies is the roles and stuff that are running on the box, the most is whether it is a database server or not. Consider the following IsSqlServer method, that uses the SPServerRole enumeration with the SPServer.Role property along with service instance testing ala SPDatabaseServiceInstance.

  1. private bool IsDatabaseServer(SPServer server)
  2.  
  3. {
  4.  
  5. if (server.Role.Equals(SPServerRole.Invalid))
  6.  
  7. {
  8.  
  9. while (server.ServiceInstances.Count > 0)
  10.  
  11. {
  12.  
  13. foreach (var instance in server.ServiceInstances)
  14.  
  15. {
  16.  
  17. if (instance is SPDatabaseServiceInstance)
  18.  
  19. {
  20.  
  21. return true;
  22.  
  23. }
  24.  
  25. }
  26.  
  27. break;
  28.  
  29. }
  30.  
  31. }
  32.  
  33. return false;
  34.  
  35. }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>