private void ValidateRemotePipeUser() { if (!IsCurrentUserOnly) { return; } PipeSecurity accessControl = this.GetAccessControl(); IdentityReference?remoteOwnerSid = accessControl.GetOwner(typeof(SecurityIdentifier)); using (WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent()) { SecurityIdentifier?currentUserSid = currentIdentity.Owner; if (remoteOwnerSid != currentUserSid) { State = PipeState.Closed; throw new UnauthorizedAccessException(SR.UnauthorizedAccess_NotOwnedByCurrentUser); } } }