WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

NT AUTHORITY\SYSTEM Toast Notifications 0x80070005 (E_ACCESSDENIED)

Open E4zily opened this issue 3 years ago • 7 comments

Describe the bug

i am trying to send a toast notification, but when the app runs as NT AUTHORITY\SYSTEM, it throws an unauthorizedaccessexception: Unhandled Exception: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at Windows.UI.Notifications.ToastNotifier.Show(ToastNotification notification) at Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat.Show(ToastNotification notification) in /_/Microsoft.Toolkit.Uwp.Notifications/Toasts/Compat/ToastNotifierCompat.cs:line 34 at Microsoft.Toolkit.Uwp.Notifications.ToastContentBuilder.Show(CustomizeToast customize) in /_/Microsoft.Toolkit.Uwp.Notifications/Toasts/Builder/ToastContentBuilder.cs:line 430 at Microsoft.Toolkit.Uwp.Notifications.ToastContentBuilder.Show() in /_/Microsoft.Toolkit.Uwp.Notifications/Toasts/Builder/ToastContentBuilder.cs:line 414

Regression

No response

Reproducible in sample app?

  • [x] This bug can be reproduced in the sample app.

Steps to reproduce

1. launch an application as NT AUTHORITY\SYSTEM
2. try sending a toast notification and it will throw an exception

Expected behavior

the notification should be sent successfully

Screenshots

No response

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 11 21H2 (Build 22000)
  • [X] Other (specify)

Other Windows Build number

Windows 10 21H2 (build 19044.2130)

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [X] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [X] Other (specify)

Other SDK version

i dont get the question

Visual Studio Version

2022

Visual Studio Build Number

17.3.3

Device form factor

No response

Nuget packages

Costura.Fody 5.7.0 Fody 6.6.4 Microsoft.NETCore.Platforms 6.0.5 Microsoft.Toolkit.Uwp.Notifications 7.1.2 Microsoft.Win32.Primitives 4.3.0 NETStandard.Library 2.0.3 System.AppContext 4.3.0 System.Collections 4.3.0 System.Collections.Concurrent 4.3.0 System.Console 4.3.1 System.Diagnostics.Debug 4.3.0 System.Diagnostics.DiagnosticSource 6.0.0 System.Diagnostics.Tools 4.3.0 System.Diagnostics.Tracing 4.3.0 System.Globalization 4.3.0 System.Globalization.Calendars 4.3.0 System.IO.Compression 4.3.0 System.IO.Compression.ZipFile 4.3.0 System.IO.FileSystem 4.3.0 System.Linq 4.3.0 System.Linq.Expressions 4.3.0 System.Net.Http 4.3.4 System.Net.Primitives 4.3.1 System.Net.Sockets 4.3.0 System.ObjectModel 4.3.0 System.Reflection 4.3.0 System.Reflection.Extensions 4.3.0 System.Reflection.Primitives 4.3.0 System.Resources.ResourceManager 4.3.0 System.Runtime 4.3.1 System.Runtime.Extensions 4.3.1 System.Runtime.Handles 4.3.0 System.Runtime.InteropServices 4.3.0 System.Runtime.InteropServices.RuntimeInformation 4.3.0 System.Runtime.Numerics 4.3.0 System.Security.Cryptography.Algorithms 4.3.1 System.Security.Cryptography.X509Certificates 4.3.2 System.Text.Encoding 4.3.0 System.Text.Encoding.Extensions 4.3.0 System.Text.RegularExpressions 4.3.1 System.Threading 4.3.0 System.Threading.Tasks 4.3.0 System.Threading.Timer 4.3.0 System.Xml.ReaderWriter 4.3.1 System.Xml.XDocument 4.3.0

Additional context

the process' parent is winlogon just in case

Help us help you

No.

E4zily avatar Oct 14 '22 13:10 E4zily

Hello E4zily, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Oct 14 '22 13:10 ghost

FYI @vaheeshta @adambarlow

michael-hawker avatar Oct 18 '22 16:10 michael-hawker

For what it is worth, we are seeing a similar issue in a few user logs/dumps. Not certain of why it only fails for some.

System.InvalidOperationException
  HResult=0x80131509
  Message=Failed to register notification activator
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

  This exception was originally thrown at this call stack:
    Microsoft.Win32.RegistryKey.Win32Error(int, string) in registrykey.cs
    Microsoft.Win32.RegistryKey.SetValue(string, object, Microsoft.Win32.RegistryValueKind) in registrykey.cs
    Microsoft.Win32.RegistryKey.SetValue(string, object) in registrykey.cs
    Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.RegisterComServer(System.Type, string) in ToastNotificationManagerCompat.cs
    Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.RegisterActivator(System.Type) in ToastNotificationManagerCompat.cs
    Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.CreateAndRegisterActivator() in ToastNotificationManagerCompat.cs
    Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.OnActivated.add(Microsoft.Toolkit.Uwp.Notifications.OnActivated) in ToastNotificationManagerCompat.cs

Inner Exception 1:
UnauthorizedAccessException: Attempted to perform an unauthorized operation.


	Microsoft.Toolkit.Uwp.Notifications.dll!Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat.CreateToastNotifier() Line 400	C#
 	Microsoft.Toolkit.Uwp.Notifications.dll!Microsoft.Toolkit.Uwp.Notifications.ToastContentBuilder.Show(Microsoft.Toolkit.Uwp.Notifications.CustomizeToast customize) Line 428	C#

mbragg12 avatar Nov 03 '22 19:11 mbragg12

FYI @loneursid

vaheeshta avatar Nov 04 '22 16:11 vaheeshta

Same Exception when run windows service from user account, Exception thrown: 'System.UnauthorizedAccessException' in Microsoft.Toolkit.Uwp.Notifications.dll An exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.Toolkit.Uwp.Notifications.dll but was not handled in user code Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

MohamedSSaleh avatar Dec 02 '22 23:12 MohamedSSaleh

We do not currently support notifications for non-user context, however this is not explicit in the documentation.

pmpurifoy avatar Jan 04 '23 18:01 pmpurifoy

Any resolution so far?

I'm getting this error even in Windows 11 - 23H2

SalehBagheri avatar Jan 05 '24 06:01 SalehBagheri