GVKun编程网logo

写入事件日志时出现 System.Security.SecurityException(日志写入失败)

16

在本文中,我们将给您介绍关于写入事件日志时出现System.Security.SecurityException的详细内容,并且为您解答日志写入失败的相关问题,此外,我们还将为您提供关于.net–在S

在本文中,我们将给您介绍关于写入事件日志时出现 System.Security.SecurityException的详细内容,并且为您解答日志写入失败的相关问题,此外,我们还将为您提供关于.net – 在SQL Server上执行用户定义函数时出现System.Security.HostProtectionException、80-c# 报错 System.Security.SecurityException 未找到源(无法启动计算机“.”上的服务)、Android M 6.0 – SecurityException试图删除帐户、android – SecurityException:权限拒绝错误的知识。

本文目录一览:

写入事件日志时出现 System.Security.SecurityException(日志写入失败)

写入事件日志时出现 System.Security.SecurityException(日志写入失败)

我正在尝试将 ASP.NET 应用程序从 Server 2003(和 IIS6)移植到 Server 2008 (IIS7)。

当我尝试访问浏览器上的页面时,我得到了这个:

“/”应用程序中的服务器错误。

安全异常

说明:应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请联系您的系统管理员或在配置文件中更改应用程序的信任级别。

异常详细信息:System.Security.SecurityException:找不到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性

源错误:

在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。

堆栈跟踪:

[SecurityException:未找到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性。]

System.Diagnostics.EventLog.FindSourceRegistration(String source, String
machineName, Boolean readOnly) +562
System.Diagnostics.EventLog.SourceExists(String source, String machineName)
+251

[剪辑]

这些是我为尝试解决它所做的事情:

  1. 授予“所有人”对密钥的完全访问权限HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security。这行得通。但我自然可以在生产中做到这一点。所以我在运行应用程序几分钟后删除了“所有人”权限,错误再次出现。

  2. 我在安装过程中使用提升的权限在应用程序日志和安全日志中创建了源(并通过 regedit 验证了它存在),但错误仍然存​​在。

  3. 我在文件中为应用程序提供了完全信任级别web.config(并使用appcmd.exe),但无济于事。

有没有人知道在这里可以做什么?

答案1

小编典典

解决方案是授予“网络服务”帐户对 EventLog/Security 密钥的读取权限。

.net – 在SQL Server上执行用户定义函数时出现System.Security.HostProtectionException

.net – 在SQL Server上执行用户定义函数时出现System.Security.HostProtectionException

我编写了一个用户定义函数,它获取UtcTimeStamp和 windowstimezoneid作为参数,并返回TimeZone的TimeStamp.

但如果我想在一个简单的选择中执行它我得到以下错误:

A .NET Framework error occurred during execution of user-defined routine or aggregate "ToLocalTime": 
System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host.

The protected resources (only available with full trust) were: All
The demanded resources were: MayLeakOnAbort

System.Security.HostProtectionException: 
   bei TimeFunctions.ToLocalTime(DateTime UtcTimestamp,String WindowsTimeZoneId)

我执行select as sa.我将clr设置为1.我使用sql Server 2008 R2(10.50.1600).

有谁知道我必须设置什么才能使这个工作或我可能做错了什么?

解决方法

CLR程序集有 trust levels.

这个需要UNSAFE权限,因为使用“MayLeakOnAbort”所需的权利

将CLR更改为更安全的内容,或者使用UNSAFE权限重新添加程序集. “UNSAFE”这个词当然是……

80-c# 报错 System.Security.SecurityException 未找到源(无法启动计算机“.”上的服务)

80-c# 报错 System.Security.SecurityException 未找到源(无法启动计算机“.”上的服务)

应用场景:
利用c#创建windows服务,c#程序默认没有管理员的权限。
服务安装虽然成功,
但在启动时:提示: 无法启动计算机“.”上的服务
看日志: System.Security.SecurityException 未找到源。
配置下以管理员身份运行。
配置过程:
(1)在要编译的项目上右击选择【属性】然后选择【安全性】再勾选上【启用ClickOnce安全设置】,此时会在解决方案资源管理器的Properties中生成app.manifest文件。

(2)双击打开生成的app.manifest文件,找到如下代码:

<requestedExecutionLevel level="asInvoker" uiAccess="false" />  

将其修改为:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

(3)然后在【安全性】中去掉对【启用ClickOnce安全设置】的勾选,全部保存后重新编译就可以了。

参考来源:
https://blog.csdn.net/songyi160/article/details/49926433

Android M 6.0 – SecurityException试图删除帐户

Android M 6.0 – SecurityException试图删除帐户

我有一个使用 Android AccountManager(包名:com.mycompany.accounts)的应用程序,它将帐户添加到设备并提供登录屏幕.我有另一个应用程序(com.mycomp.actualapp),它使用第一个应用程序添加/删除帐户.

我可以使用清单中的以下权限在Pre Marshmallow设备上成功添加和删除帐户:

<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>

使用sdk 22进行编译并使用sdk 22进行编译时,应自动授予这些权限.以下代码:

accountManager.removeAccount(getAccount(),activity,new AccountManagerCallback<Bundle>() {
        @Override
        public void run(AccountManagerFuture<Bundle> accountManagerFuture) {
            try {
                Bundle bundle = accountManagerFuture.getResult();
                boolean success = bundle.getBoolean(AccountManager.KEY_BOOLEAN_RESULT);
                if (success) {
                    Toast.makeText(activity,activity.getString(R.string.successfully_loggedout),Toast.LENGTH_LONG).show();
                    afterlogoutSuccess(activity);

                } else {
                    Toast.makeText(activity.getApplicationContext(),activity.getString(R.string.Failed_to_logout),Toast.LENGTH_LONG).show();
                }
                onlogoutListener.onlogoutFinished(success);
                return;
            } catch (OperationCanceledException e) {
                Log.e(TAG,"Operation cancelled exception:",e);
            } catch (IOException e) {
                Log.e(TAG,"IOException:",e);
            } catch (AuthenticatorException e) {
                Log.e(TAG,"AuthenticatorException:",e);
            }
            onlogoutListener.onlogoutFinished(false);

        }
    },null);

失败,出现以下异常:

java.lang.SecurityException: uid 10057 cannot remove accounts of type: com.mycompany.accounts
        at android.os.Parcel.readException(Parcel.java:1599)
        at android.os.Parcel.readException(Parcel.java:1552)
        at android.accounts.IAccountManager$Stub$Proxy.removeAccount(IAccountManager.java:897)
        at android.accounts.AccountManager$7.doWork(AccountManager.java:900)
        at android.accounts.AccountManager$AmsTask.start(AccountManager.java:1888)
        at android.accounts.AccountManager.removeAccount(AccountManager.java:897)
        at com.mycomp.actualapp.utils.LoginHelper$4.doInBackground(LoginHelper.java:282)
        at com.mycomp.actualapputils.LoginHelper$4.doInBackground(LoginHelper.java:242)
        at android.os.AsyncTask$2.call(AsyncTask.java:295)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)

奇怪的是,这个代码在Pre Marshmallow设备上运行正常,没有任何问题.

在旁注中,我注意到使用sdk 22进行编译并且定位22:转到“设置>应用>我的应用(com.mycomp.actualapp)>权限”我只看到两个权限,“电话”“存储” .

我注意到用sdk 23编译并且目标23:我看到三个权限,“电话”,“存储”和“联系人”.

我尝试过以下方法:

>切换到使用sdk 23编译 – 在应用程序设置中授予所有权限,再次尝试删除帐户.仍然失败,同样的例外.
>使用22进行编译并将以下权限添加到清单中.确保授予所有权限.仍然失败,同样的例外:

<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>

我可以在没有其他权限授予的情况下获取用户帐户用户名和令牌,但删除帐户不起作用.
我真的很感激任何帮助!

解决方法

昨天我突然陷入了同样的困境.
就我而言,我在节点中定义了错误的包名称.
只需修复它就能完美运行.

<帐户认证符>
的xmlns:机器人= “http://schemas.android.com/apk/res/android”
android:accountType =“你的正确数据包名称”“.accounts”
机器人:图标= “@绘制/ ic_launcher”
机器人:标签= “XXX”
机器人:smallIcon = “@绘制/ ic_launcher”
>
< /帐户认证符>

如果您的包裹名称是:com.example.android然后帐户类型应该是:com.example.android.accounts

android – SecurityException:权限拒绝错误

android – SecurityException:权限拒绝错误

我刚刚升级到新版本的gmail(v2.3.5),我有一个应用程序查询内容提供商,以获取有关收到消息的联系人的详细信息……

使用最新版本我收到以下错误:

java.lang.SecurityException: Permission Denial: opening provider com.google.android.gm.provider.MailProvider from ProcessRecord{40adef58 3576:com.rageconsulting.android.lightflow/10056} (pid=3576, uid=10056) requires com.google.android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL`

对于我的清单中的gmail,我声明了以下内容:

<!--permissions for gmail-->
<uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="com.google.android.providers.gmail.permission.READ_GMAIL"/>
<uses-permission android:name="com.google.android.gm.permission.READ_GMAIL"/>
<uses-permission android:name="com.google.android.gm.permission.WRITE_GMAIL"/>

所以据我所知,我的权限是正确的.

我的gmail接收器如下所示:

    <receiver android:name=".receiver.GmailReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PROVIDER_CHANGED" android:priority="-10">
            </action>
            <data android:scheme="content" android:host="gmail-ls" android:pathPattern="/unread/.*">
            </data>
        </intent-filter>


        <intent-filter>
            <action android:name="android.intent.action.PROVIDER_CHANGED" android:priority="-10">
            </action>
            <data android:mimeType="*/*" android:scheme="content" android:host="gmail-ls" android:path="/unread/^i">
            </data>
        </intent-filter>

    </receiver>

谁能想到我可能错过的东西?

解决方法:

谷歌出于“安全原因”打破了它.看到这个支持线程:

http://www.google.com/support/forum/p/gmail/thread?fid=1728955d050a12bd0004a9339272acdb&hl=en

你需要回到2.3.5之前的版本,即2.3.4.1

今天关于写入事件日志时出现 System.Security.SecurityException日志写入失败的介绍到此结束,谢谢您的阅读,有关.net – 在SQL Server上执行用户定义函数时出现System.Security.HostProtectionException、80-c# 报错 System.Security.SecurityException 未找到源(无法启动计算机“.”上的服务)、Android M 6.0 – SecurityException试图删除帐户、android – SecurityException:权限拒绝错误等更多相关知识的信息可以在本站进行查询。

本文标签: