/// <summary>
 /// Initialize a new IIS Application Pool.
 /// </summary>
 /// <param name="name">Name of the application pool.</param>
 /// <param name="user">User to run the application pool.</param>
 /// <param name="type">Identity type of application pool.</param>
 protected ApplicationPool(
     string name,
     WindowsUser user,
     ApplicationPoolIdentityType type)
 {
     this.Name         = name;
     this.User         = user;
     this.IdentityType = type;
 }
 /// <summary>
 /// Initialize a new IIS Application Pool, not for a specific user.
 /// </summary>
 /// <param name="name">Name of the application pool.</param>
 /// <param name="type">Any type except for SpecificUser.</param>
 public ApplicationPool(string name, ApplicationPoolIdentityType type)
     : this(name, null, type)
 {
     if (type == ApplicationPoolIdentityType.SpecificUser)
     {
         throw new ArgumentException(
                   "Setting a specific user is not " +
                   "supported by this constructor");
     }
 }
Esempio n. 3
0
        static IdentityReference GetIdentityForApplicationPoolIdentity(ApplicationPoolIdentityType applicationPoolIdentityType,
                                                                       VariableDictionary variables)
        {
            switch (applicationPoolIdentityType)
            {
            case ApplicationPoolIdentityType.ApplicationPoolIdentity:
                return(new NTAccount("IIS AppPool\\" + variables.Get(SpecialVariables.Action.IisWebSite.ApplicationPoolName)));

            case ApplicationPoolIdentityType.LocalService:
                return(new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null));

            case ApplicationPoolIdentityType.LocalSystem:
                return(new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null));

            case ApplicationPoolIdentityType.NetworkService:
                return(new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null));

            case ApplicationPoolIdentityType.SpecificUser:
                return(new NTAccount(StripLocalAccountIdentifierFromUsername(variables.Get(SpecialVariables.Action.IisWebSite.ApplicationPoolUserName))));

            default:
                throw new ArgumentOutOfRangeException(nameof(applicationPoolIdentityType), applicationPoolIdentityType, null);
            }
        }