【问题标题】:Cannot open log for source 'Microsoft.Practices.EnterpriseLibrary.Data'. You may not have write access When Read/Write to Event log无法打开源“Microsoft.Practices.EnterpriseLibrary.Data”的日志。读取/写入事件日志时,您可能没有写入权限
【发布时间】:2024-01-22 06:02:01
【问题描述】:

我正在开发一个 SharePoint 2013 网站,我有 2 种类型的注册:(Win 身份验证和 FBA)。
我正在尝试使用旧门户(SP 2010)中的解决方案(WSP),这个 WSP 使用一个名为 'Microsoft.Practices.EnterpriseLibrary.Data' 的 dll在 SP 2013 环境中不存在。

因此,为了解决我从 Microsoft 安装了 Microsoft Enterprise Library 5.0,然后我将此 dll 复制到 inetpub\wwwroot\wss\VirtualDirectories\80\ 下的 bin 文件夹中

现在,当我使用 Windows 身份验证模式登录网站时,WebPart 出现,但以 FBA 用户身份登录时出现错误:

System.InvalidOperationException: Cannot open log for source 'Microsoft.Practices.EnterpriseLibrary.Data'. You may not have write access. ---> System.ComponentModel.Win32Exception: Access is denied
   --- End of inner exception stack trace ---
   at System.Diagnostics.EventLogInternal.OpenForWrite(String currentMachineName)
   at System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
   at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type)
   at ProjectName.Internet.EventViewerLogService.LogEvent(String source, String message, EventLogEntryType type)
   at ProjectName.Internet.ExceptionHandler.Handle(Exception exception)
   at ProjectName.Internet.SQLHelper.GetVolunteerInfo(String VolunteerId)
   at ProjectName.Internet.Profiles.Volunteer.GetVolunteer(String VolunteerId)
   at ProjectName.Internet.Accessibility.Accessibility.AccessibilityUserControl.Page_Load(Object sender, EventArgs e)


注意:我试图将“安全”权限授予注册表 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security 到 'Authenticated Users 组',因为我一开始就有错误 错误:未找到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性。

PS:这是对此的跟进。我按照给定的答案,但无济于事。

我猜这是由于服务器上的一些配置问题造成的?

【问题讨论】:

    标签: exception-handling sharepoint-2013 event-log windows-server-2012 securityexception


    【解决方案1】:

    该错误与权限问题有关,当我使用 FBA 用户登录时,我错过了写入新事件源的权限。

    默认情况下,任何经过身份验证的用户都可以写入应用程序事件日志。但是只有管理员可以创建新的事件源。

    我通过使用提升的权限运行 CreateEventSource 方法来解决它,如下所示:

    SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    if (!EventLog.SourceExists(eSource))
                    {
                        EventLog.CreateEventSource(eSource, eLog);
                    }
                    EventLog.WriteEntry(eSource, ex.ToString(), EventLogEntryType.Error);
                });
    

    【讨论】:

      最近更新 更多