Solved

Get User ID from EVENTLOGRECORD

Posted on 1997-07-09
9
504 Views
Last Modified: 2013-12-03
I think this question is quite straight forward.....but I dun know how to go about it.....my question:

How can I get User ID from EVENTLOGRECORD?  

Example:
If I have a EVENTLOGRECORD pointer that points to a record, how do I print that user ID using that record pointer, to a string?

I think that maybe using UserSidOffset or/and UserSidLength might help.....but I don't know how to.

Any suggestion will be appreciated.
0
Comment
Question by:YamSeng
  • 6
  • 3
9 Comments
 
LVL 1

Author Comment

by:YamSeng
ID: 1400483
Adjusted points to 20
0
 
LVL 5

Accepted Solution

by:
y96andha earned 50 total points
ID: 1400484
You need to use the LookupAccountSid function. Just pass in the pointer to the SID, and you will receive the name of the user and the domain the account was found on.
0
 
LVL 1

Author Comment

by:YamSeng
ID: 1400485
Ho do I get the sid?

pEventLogRecord + pEventLogRecord->UserSidOffset  ?
and pEventLogRecord->UserSidLength ?

Can show me a sample?  
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1400486
20 points is not much.

if(pEventLogRecord->UserSidLength) {
 PSID sp;
 sp = (PSID)(((char *)pEventLogRecord) + pEventLogRecord->UserSidOffset);

 SID_NAME_USE snu;
 DWORD len1,len2;
 int ok;
 TCHAR name[256],dom[256];
 len1=len2=256;
 ok = LookupAccountSid(0,sp,name,&len1,dom,&len2,&snu);
 if(ok) {
   // Success
 } else {
  printf("Error: %d\n",GetLastError());  
 }
}

I have not tested this code, but it should work.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:YamSeng
ID: 1400487
sorry about the points, but I a new member and I dun have much points.....

anyway, I've increased the points....
0
 
LVL 1

Author Comment

by:YamSeng
ID: 1400488
If you can help me, I can only offer this much....sorry!
0
 
LVL 1

Author Comment

by:YamSeng
ID: 1400489
I've tried the codes, but found that it gives the user that I do not want.  I want the user name.

If you go to event viewer, you can see that under security log, details for eventID 529 (failed to logon) has 2 "user".  One is "user" the other is "user name"

For example:
If my name is ash and I failed to logon to NT workstation, the event viewer should show

user = system
username = ash

The user name is the value I want to find out.....

thanks!

0
 
LVL 5

Expert Comment

by:y96andha
ID: 1400490
OK, you mean the name in the description box?

This is found in one of the strings, I am not sure which one, and I currently don't have any such entries in my log. You could test it out yourself. The strings are accessed like this:

 TCHAR *p;
 p = (TCHAR *)(((char *)pEventLogRecord) + pEventLogRecord->StringOffset);

 int i;
 for(i=0;i<pEventLogRecord->NumStrings;i++) {
  wprintf(L"String %d : %s\n", i, p);
  p+=_tcslen(p)+1;
 }

0
 
LVL 1

Author Comment

by:YamSeng
ID: 1400491
Thanks!!!  I've got it...

FYI, the user name is in string 0.  
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now