简体   繁体   English

将事件写入事件日志期间的WCF异常

[英]WCF Exception during writing an event into event log

Exception during writing event log on host machine(Windows 2008 R2) hosting WCF Service named my machine from WCFClient (Windows 7) running within domain but on a different machine. 在宿主WCF服务的主机(Windows 2008 R2)上,从运行在域中但在另一台计算机上运行的WCFClient(Windows 7)命名了我的计算机的事件日志中写入异常。

WCF Client is impersonated to access resources on Server. WCF客户端被模拟为访问服务器上的资源。

So far following links have not helped 到目前为止,以下链接没有帮助

http://support.microsoft.com/kb/2028427#appliesto http://support.microsoft.com/kb/2028427#appliesto

http://forums.asp.net/t/1131903.aspx http://forums.asp.net/t/1131903.aspx

http://msdn.microsoft.com/en-us/library/Aa379567 (Detals about SDDL) http://blogs.dirteam.com/blogs/jorge/archive/2008/03/26/parsing-sddl-strings.aspx (SDDL) http://msdn.microsoft.com/zh-cn/library/Aa379567 (有关SDDL的详细信息) http://blogs.dirteam.com/blogs/jorge/archive/2008/03/26/parsing-sddl-strings。 aspx (SDDL)

similar question on SO without any answer https://stackoverflow.com/questions/6456444/allow-wcf-services-writing-to-custom-event-log-under-windows-2008-r2-server SO上类似的问题而没有任何答案https://stackoverflow.com/questions/6456444/allow-wcf-services-writing-to-custom-event-log-under-windows-2008-r2-server

Exception is as follows 异常如下

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Cannot open log for source 'MyService'. System.ServiceModel.FaultException`1 [System.ServiceModel.ExceptionDetail]:无法打开源“ MyService”的日志。 You may not have write access. 您可能没有写权限。 (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.InvalidOperationException: Cannot open log for source 'MyService'. You may not have write access. ----> System.ComponentModel.Win32Exception: Access is denied (故障详细信息等于ExceptionDetail,可能由IncludeExceptionDetailInFaults = true创建,其值为:System.InvalidOperationException:无法打开源“ MyService”的日志。您可能没有写权限。----> System.ComponentModel.Win32Exception :访问被拒绝

--- End of inner ExceptionDetail 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 message, EventLogEntryType type) ................... ..................... ---内部ExceptionDetail堆栈跟踪的结尾---在System.Diagnostics.EventLogInternal.OpenForWrite(String currentMachineName),在System.Diagnostics.EventLogInternal.InternalWriteEvent(UInt32 eventID,UInt16 category,EventLogEntryType type,String []字符串,字节[] RawData,位于System.Diagnostics.EventLogInternal.WriteEntry(字符串消息,EventLogEntryType类型,Int32 eventID,Int16类别,Byte [] rawData),位于System.Diagnostics.EventLog.WriteEntry(字符串消息,EventLogEntryType类型)...。 ...................................................

Is this a custom event log? 这是自定义事件日志吗? If so, refer to 如果是这样,请参阅

http://msdn.microsoft.com/en-us/library/49dwckkz(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/49dwckkz(v=vs.80).aspx

-- and in particular -特别是

In general, create the new event source during the installation of your application. 通常,在安装应用程序期间创建新的事件源。 This allows time for the operating system to refresh its list of registered event sources and their configuration. 这使操作系统有时间刷新其已注册事件源及其配置的列表。 If the operating system has not refreshed its list of event sources and you attempt to write an event with the new source, the write operation will fail. 如果操作系统尚未刷新其事件源列表,并且您尝试使用新的源写入事件,则写入操作将失败。 If creating the source during installation is not an option, then try to create the source well ahead of the first write operation, perhaps during your application initialization. 如果无法在安装过程中创建源,请尝试在首次写入操作之前(可能是在应用程序初始化期间)创建源。 If you choose this approach, be sure your initialization code is running with administrator rights on the computer. 如果选择这种方法,请确保初始化代码正在计算机上以管理员权限运行。 These rights are required for creating new event sources. 这些权限是创建新事件源所必需的。

Modified ProcesModel's Identity of AppPool from NetworkService to LocalSystem and everything is working. 修改了ProcesModel的AppPool的标识(从NetworkService到LocalSystem),一切正常。

Although this is not public facing site and is a corporate distributed setup which will run within its own domain but one can still argue about security risk. 尽管这不是面向公众的站点,而是一种企业分布式设置,可以在其自己的域中运行,但是仍然可以争论安全风险。

and possible solution can be 和可能的解决方案可以是

To separate the Event writing code from Imperosnation 将事件编写代码与Imperosnation分开

or just elevate permission for offending code. 或只是提高对违规代码的许可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM