473,582 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows EventLog - populating User field

Hi

I'm using the following code in a global class to add to the Windows
EventLog every time a try{} catch{} block fails...

if(!EventLog.So urceExists("dar ts"))
EventLog.Create EventSource("da rts", "Darts");

EventLog.WriteE ntry("darts", msg, EventLogEntryTy pe.Error);

This works great, but it doesn't populate the User field in the EventLog (it
says N/A). I'd like this to be populated with the value of
HttpContext.Cur rent.User.Ident ity.Name.

Is it possible to populate this field!?
Mar 30 '06 #1
3 6590
Hi muso,

Thank you for posting.

As for the .net EventLog Class's WriteEntry method, it calls the win32
"ReportEven t" API internally, also it always set "Null" to the userid
parameter for the ReportEvent API, this is why the written event entry
won't contains username info. Also, generally the userid info is not quite
used for application eventlog, it is mainly used for security log. If you
want to attach username info to the application eventlog (through .NET
api), you can consider append it to other text field like description.
Otherwise, we may need to directly use the WIN32 API to write eventlog
entry...
Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Mar 31 '06 #2
Hi Steven

Thanks for the reply... I'm thinking I'll find another way round this,
rather than delving into WIN32... the project doesn't warrant the time
necessary!

Cheers for the response!
Dan

"Steven Cheng[MSFT]" wrote:
Hi muso,

Thank you for posting.

As for the .net EventLog Class's WriteEntry method, it calls the win32
"ReportEven t" API internally, also it always set "Null" to the userid
parameter for the ReportEvent API, this is why the written event entry
won't contains username info. Also, generally the userid info is not quite
used for application eventlog, it is mainly used for security log. If you
want to attach username info to the application eventlog (through .NET
api), you can consider append it to other text field like description.
Otherwise, we may need to directly use the WIN32 API to write eventlog
entry...
Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




Apr 1 '06 #3
Thanks for the response Dan,

Please feel free to let me know if there's anything else we can help.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4113
by: Joe | last post by:
I am trying to read the EventLog of different servers on the network. If I run the script in a command line, it works well. But when I try to put the script into the Web server (IIS in Windows 2000) and run from a web browser, it works with my local machine only. I have the following error when I try to access any remote server: CGI...
2
9530
by: Steph | last post by:
I am working on a Windows Forms App. I have attached a standard UnhandledExceptionEventHandler to the current domain to catch unexpected errors. In my application, when I trigger an unhandled error, my handler does not get hit - I get the standard ugly run time error. The strange thing is, I tried the exact same code in a new, windows...
3
4403
by: Jacob Crossley | last post by:
Hello all. We have about 10 Window's services that we wrote in c#. We use them to process row's that we have queued up in various SQL tables. The services seem to hang at least once in any given 24 hour period. Once we reset the service, it goes about its processing business until the next time it hangs. We are wondering if the hanging...
4
15522
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C# application. The command runs successfully from a Windows Form but fails if the application is recasted as a Windows service. The application is...
5
2864
by: Andrew | last post by:
Hey all, Requesting help from the VB.Net gurus in here. I was given a task to write a Windows Service (VB.Net) that would run an external program, and if that program closed for any reason (other than the service being stopped) it would restart it. I have written the service to do just this, and for testing purposes I am running the...
3
5068
by: Ahmad Jalil Qarshi | last post by:
Hi! I am developing an application in C# as a windows NT Service. This application needs to check for eventlog using EventLog.Exists("System") But unfortunately it generates exception "Requested registry access is not allowed."
27
4703
by: pisquem | last post by:
I am building an windows service that is to be deployed on a windows server 2003 and I want to have activity written to the event log, I want its own log called ('CustomLog') Below is what I have so far...its builds fine but when I go to start the service i get the following error. --------------------------- Services...
0
1795
balabaster
by: balabaster | last post by:
Hi, I know this question has been answered before (somewhat) but I have a twist... I've written a client/server application where the server portion runs as a windows service and allows connections across the network from remote users. The application all works like a charm and is very effective. However, during testing it occured to me...
5
3291
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
7809
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8183
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6569
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1413
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.