public TestSubS(RunAsUser runAsUser = RunAsUser.Originating, bool @throw = false, UnhandledExceptionHandling unhandledExceptionHandling = UnhandledExceptionHandling.Continue) : base("Test.Blah.*", "create", "update") { _throw = @throw; RunAsUser = runAsUser; UnhandledExceptionHandling = unhandledExceptionHandling; }
public static void RunAs <T>(RunAsUser user, Func <T> function) { IntPtr errorInfo; SafeAccessTokenHandle restrictedToken; GetRunAsUserToken getRunAsUserToken = ResolveGetRunAsUserTokenMethod(); Marshal.ThrowExceptionForHR(getRunAsUserToken(user, out restrictedToken, out errorInfo), errorInfo); WindowsIdentity.RunImpersonated(restrictedToken, function); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (FsGroup == null) { throw new ValidationException(ValidationRules.CannotBeNull, "FsGroup"); } if (RunAsUser == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RunAsUser"); } if (SeLinux == null) { throw new ValidationException(ValidationRules.CannotBeNull, "SeLinux"); } if (SupplementalGroups == null) { throw new ValidationException(ValidationRules.CannotBeNull, "SupplementalGroups"); } if (AllowedFlexVolumes != null) { foreach (var element in AllowedFlexVolumes) { if (element != null) { element.Validate(); } } } if (HostPorts != null) { foreach (var element1 in HostPorts) { if (element1 != null) { element1.Validate(); } } } if (RunAsGroup != null) { RunAsGroup.Validate(); } if (RunAsUser != null) { RunAsUser.Validate(); } if (SeLinux != null) { SeLinux.Validate(); } }
public TestSubS(RunAsUser runAsUser = RunAsUser.Originating, bool @throw = false, UnhandledExceptionHandling unhandledExceptionHandling = UnhandledExceptionHandling.Continue) { _throw = @throw; RunAsUser = runAsUser; UnhandledExceptionHandling = unhandledExceptionHandling; }