SecurityIdentifierElementCollection.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //------------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //------------------------------------------------------------------------------
  4. namespace System.ServiceModel.Activation.Configuration
  5. {
  6. using System;
  7. using System.Collections;
  8. using System.Configuration;
  9. using System.Globalization;
  10. using System.ServiceModel;
  11. using System.ServiceModel.Activation;
  12. using System.ServiceModel.Configuration;
  13. using System.ServiceModel.Channels;
  14. using System.Security.Principal;
  15. [ConfigurationCollection(typeof(SecurityIdentifierElement))]
  16. public sealed class SecurityIdentifierElementCollection : ServiceModelConfigurationElementCollection<SecurityIdentifierElement>
  17. {
  18. public SecurityIdentifierElementCollection() : base() { }
  19. protected override Object GetElementKey(ConfigurationElement element)
  20. {
  21. if (element == null)
  22. {
  23. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("element");
  24. }
  25. SecurityIdentifierElement configElementKey = (SecurityIdentifierElement)element;
  26. return configElementKey.SecurityIdentifier.Value;
  27. }
  28. internal void SetDefaultIdentifiers()
  29. {
  30. if (Iis7Helper.IisVersion >= 7)
  31. {
  32. this.Add(new SecurityIdentifierElement(new SecurityIdentifier(ConfigurationStrings.IIS_IUSRSSid)));
  33. }
  34. this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null)));
  35. this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null)));
  36. this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null)));
  37. this.Add(new SecurityIdentifierElement(new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null)));
  38. }
  39. }
  40. }